{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bb375284",
   "metadata": {},
   "source": [
    "# Creating Knowledge graphs from Pdf files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3e44b03b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.graphs import Neo4jGraph\n",
    "\n",
    "url = \"\"\n",
    "username =\"\"\n",
    "password = \"\"\n",
    "graph = Neo4jGraph(\n",
    "    url=url,\n",
    "    username=username,\n",
    "    password=password\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "98e7e6c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv \n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "# Add OpenAI key\n",
    "#os.environ['OPENAI_API_KEY']=''\n",
    "api_key = os.environ['OPENAI_API_KEY']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0d7f3cfc",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.graphs.graph_document import (\n",
    "    Node as BaseNode,\n",
    "    Relationship as BaseRelationship,\n",
    "    GraphDocument,\n",
    ")\n",
    "from langchain.schema import Document\n",
    "from typing import List, Dict, Any, Optional\n",
    "from langchain.pydantic_v1 import Field, BaseModel\n",
    "\n",
    "class Property(BaseModel):\n",
    "  \"\"\"A single property consisting of key and value\"\"\"\n",
    "  key: str = Field(..., description=\"key\")\n",
    "  value: str = Field(..., description=\"value\")\n",
    "\n",
    "class Node(BaseNode):\n",
    "    properties: Optional[List[Property]] = Field(\n",
    "        None, description=\"List of node properties\")\n",
    "\n",
    "class Relationship(BaseRelationship):\n",
    "    properties: Optional[List[Property]] = Field(\n",
    "        None, description=\"List of relationship properties\"\n",
    "    )\n",
    "\n",
    "# class Source(BaseSource):\n",
    "#     properties: Optional[List[Property]] = Field(\n",
    "#         None, description=\"List of sources\"\n",
    "#     )        \n",
    "        \n",
    "class KnowledgeGraph(BaseModel):\n",
    "    \"\"\"Generate a knowledge graph with entities and relationships.\"\"\"\n",
    "    nodes: List[Node] = Field(\n",
    "        ..., description=\"List of nodes in the knowledge graph\")\n",
    "    rels: List[Relationship] = Field(\n",
    "        ..., description=\"List of relationships in the knowledge graph\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2206d78a",
   "metadata": {},
   "outputs": [],
   "source": [
    "def format_property_key(s: str) -> str:\n",
    "    words = s.split()\n",
    "    if not words:\n",
    "        return s\n",
    "    first_word = words[0].lower()\n",
    "    capitalized_words = [word.capitalize() for word in words[1:]]\n",
    "    return \"\".join([first_word] + capitalized_words)\n",
    "\n",
    "def props_to_dict(props) -> dict:\n",
    "    \"\"\"Convert properties to a dictionary.\"\"\"\n",
    "    properties = {}\n",
    "    if not props:\n",
    "      return properties\n",
    "    for p in props:\n",
    "        properties[format_property_key(p.key)] = p.value\n",
    "    return properties\n",
    "\n",
    "def map_to_base_node(node: Node) -> BaseNode:\n",
    "    \"\"\"Map the KnowledgeGraph Node to the base Node.\"\"\"\n",
    "    properties = props_to_dict(node.properties) if node.properties else {}\n",
    "    # Add name property for better Cypher statement generation\n",
    "    properties[\"name\"] = node.id.title()\n",
    "    return BaseNode(\n",
    "        id=node.id.title(), type=node.type.capitalize(), properties=properties\n",
    "    )\n",
    "\n",
    "\n",
    "def map_to_base_relationship(rel: Relationship) -> BaseRelationship:\n",
    "    \"\"\"Map the KnowledgeGraph Relationship to the base Relationship.\"\"\"\n",
    "    source = map_to_base_node(rel.source)\n",
    "    target = map_to_base_node(rel.target)\n",
    "    properties = props_to_dict(rel.properties) if rel.properties else {}\n",
    "    return BaseRelationship(\n",
    "        source=source, target=target, type=rel.type, properties=properties\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eaf6d19f",
   "metadata": {},
   "source": [
    "# Using GPT-3.5-turbo-16k model to create the knowledge graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "505a5db2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from langchain.chains.openai_functions import (\n",
    "    create_openai_fn_chain,\n",
    "    create_structured_output_chain,\n",
    ")\n",
    "from langchain_openai import ChatOpenAI\n",
    "from langchain.prompts import ChatPromptTemplate\n",
    "\n",
    "# os.environ[\"OPENAI_API_KEY\"] = \"sk-\"\n",
    "llm = ChatOpenAI(model=\"gpt-3.5-turbo-16k\", temperature=0)\n",
    "\n",
    "def get_extraction_chain(\n",
    "    allowed_nodes: Optional[List[str]] = None,\n",
    "    allowed_rels: Optional[List[str]] = None\n",
    "    ):\n",
    "    prompt = ChatPromptTemplate.from_messages(\n",
    "        [(\n",
    "          \"system\",\n",
    "          f\"\"\"# Knowledge Graph Instructions for GPT-4\n",
    "## 1. Overview\n",
    "You are a top-tier algorithm designed for extracting information in structured formats to build a knowledge graph.\n",
    "- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
    "- The aim is to achieve simplicity and clarity in the knowledge graph, making it accessible for a vast audience.\n",
    "## 2. Labeling Nodes\n",
    "- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
    "  - For example, when you identify an entity representing a person, always label it as **\"person\"**. Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
    "- **Node IDs**: Never utilize integers as node IDs. Node IDs should be names or human-readable identifiers found in the text.\n",
    "{'- **Allowed Node Labels:**' + \", \".join(allowed_nodes) if allowed_nodes else \"\"}\n",
    "{'- **Allowed Relationship Types**:' + \", \".join(allowed_rels) if allowed_rels else \"\"}\n",
    "## 3. Handling Numerical Data and Dates\n",
    "- Numerical data, like age or other related information, should be incorporated as attributes or properties of the respective nodes.\n",
    "- **No Separate Nodes for Dates/Numbers**: Do not create separate nodes for dates or numerical values. Always attach them as attributes or properties of nodes.\n",
    "- **Property Format**: Properties must be in a key-value format.\n",
    "- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
    "- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
    "## 4. Coreference Resolution\n",
    "- **Maintain Entity Consistency**: When extracting entities, it's vital to ensure consistency.\n",
    "If an entity, such as \"John Doe\", is mentioned multiple times in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
    "always use the most complete identifier for that entity throughout the knowledge graph. In this example, use \"John Doe\" as the entity ID.\n",
    "Remember, the knowledge graph should be coherent and easily understandable, so maintaining consistency in entity references is crucial.\n",
    "## 5. Strict Compliance\n",
    "Adhere to the rules strictly. Non-compliance will result in termination.\n",
    "          \"\"\"),\n",
    "            (\"human\", \"Use the given format to extract information from the following input: {input}\"),\n",
    "            (\"human\", \"Tip: Make sure to answer in the correct format\"),\n",
    "        ])\n",
    "    return create_structured_output_chain(KnowledgeGraph, llm, prompt, verbose=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "cf8b15fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "def extract_and_store_graph(\n",
    "    document: Document,\n",
    "    nodes:Optional[List[str]] = None,\n",
    "    rels:Optional[List[str]]=None) -> None:\n",
    "    # Extract graph data using OpenAI functions\n",
    "    extract_chain = get_extraction_chain(nodes, rels)\n",
    "    data = extract_chain.invoke(document.page_content)['function']\n",
    "    # Construct a graph document\n",
    "    graph_document = GraphDocument(\n",
    "      nodes = [map_to_base_node(node) for node in data.nodes],\n",
    "      relationships = [map_to_base_relationship(rel) for rel in data.rels],\n",
    "      source = document\n",
    "    )\n",
    "    # Store information into a graph\n",
    "    print(graph_document)\n",
    "    graph.add_graph_documents([graph_document])\n",
    "    return graph_document"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34e402fa",
   "metadata": {},
   "source": [
    "# With 200 chunk size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b7552cce",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from langchain.text_splitter import TokenTextSplitter\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from datetime import datetime\n",
    "\n",
    "loader = PyPDFLoader(\"../data/Apple stock during pandemic.pdf\")\n",
    "start_time = datetime.now()\n",
    "pages = loader.load_and_split()\n",
    "# Define chunking strategy\n",
    "text_splitter = TokenTextSplitter(chunk_size=200, chunk_overlap=20)\n",
    "chunks = text_splitter.split_documents(pages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "249d841a",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/23 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Stockprice', type='Concept', properties={'name': 'Stockprice'}), Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stockprice', type='Concept', properties={'name': 'Stockprice'}), type='has'), Relationship(source=Node(id='Stockprice', type='Concept', properties={'name': 'Stockprice'}), target=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), type='during')] source=Document(page_content=\"The Changes of Apple’s Stock Price During the \\nPandemic  \\nWanting Sun1,* \\n1WendySun, Kinglee High School, Zheng Zhou, He Nan, China, 450000  \\n*Corresponding author. Email:  wendysun040718@163.com  \\nABSTRACT  \\nDuring the epidemic, the economies of various countries, including many large companies, were subject to very large \\nfluctuations and impacts. Therefore, this article will explore the ups and downs of Apple's stock price duri ng the \\nepidemic. At different points in time and severity, Apple's stock price has risen and fallen. By observing the data on \\nYahoo, we can summarize Apple's stock price changes during this period. At the beginning of the epidemic, the global \\neconomy has b een damaged, so Apple is no exception. So at the beginning\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  4%|▍         | 1/23 [00:04<01:46,  4.85s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economy', type='Concept', properties={'name': 'Economy'}), Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'})] relationships=[Relationship(source=Node(id='Economy', type='Concept', properties={'name': 'Economy'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='has been damaged'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), type='fell sharply'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'}), type='impacted'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), type='fell slightly'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), type='decline resolved'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), type='increased'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'}), type='impact')] source=Document(page_content=\" \\neconomy has b een damaged, so Apple is no exception. So at the beginning of the epidemic, Apple's stock price fell \\nsharply. But later, because Apple had a strong overall strength and a good foundation, it only took three months to \\nsolve the impact of the epidemic. Later , when the epidemic returned to a serious situation, Apple's stock price was \\nimplicated and fell slightly, but within a few weeks the stock price decline was resolved and returned to normal levels, \\nand even steadily increased. Because Apple has been consta ntly launching new products, the epidemic will not have a \\nvery large impact on Apple's stock price.  \\nKeywords:  Apple, stock price, COVID -19  \\n1. INTRODUCTION  \\nAs we know, the outbreak of the epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies.\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  9%|▊         | 2/23 [00:13<02:34,  7.37s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), Node(id='2020', type='Year', properties={'name': '2020'}), Node(id='Countries', type='Group', properties={'name': 'Countries'}), Node(id='Companies', type='Group', properties={'name': 'Companies'}), Node(id='Population Decline', type='Concept', properties={'name': 'Population Decline'}), Node(id='Economic Losses', type='Concept', properties={'name': 'Economic Losses'}), Node(id='National Unrest', type='Concept', properties={'name': 'National Unrest'}), Node(id='U.S. Economic Recession', type='Event', properties={'name': 'U.S. Economic Recession'}), Node(id='Euro Zone Economy', type='Concept', properties={'name': 'Euro Zone Economy'}), Node(id='British Economy', type='Concept', properties={'name': 'British Economy'}), Node(id='World War Ii', type='Event', properties={'name': 'World War Ii'}), Node(id=\"China'S Transportation\", type='Concept', properties={'name': \"China'S Transportation\"}), Node(id='Tourism', type='Concept', properties={'name': 'Tourism'}), Node(id=\"China'S Industries\", type='Group', properties={'name': \"China'S Industries\"}), Node(id='Chinese Economy', type='Concept', properties={'name': 'Chinese Economy'}), Node(id='World Economy', type='Concept', properties={'name': 'World Economy'}), Node(id='Industry Giants', type='Group', properties={'name': 'Industry Giants'}), Node(id='Apple Company', type='Company', properties={'name': 'Apple Company'})] relationships=[Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id='2020', type='Year', properties={'name': '2020'}), type='occurred_in'), Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='affected'), Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id='Companies', type='Group', properties={'name': 'Companies'}), type='affected'), Relationship(source=Node(id='Population Decline', type='Concept', properties={'name': 'Population Decline'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='caused_by'), Relationship(source=Node(id='Economic Losses', type='Concept', properties={'name': 'Economic Losses'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='caused_by'), Relationship(source=Node(id='National Unrest', type='Concept', properties={'name': 'National Unrest'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='caused_by'), Relationship(source=Node(id='U.S. Economic Recession', type='Event', properties={'name': 'U.S. Economic Recession'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='affected'), Relationship(source=Node(id='U.S. Economic Recession', type='Event', properties={'name': 'U.S. Economic Recession'}), target=Node(id='Economic Losses', type='Concept', properties={'name': 'Economic Losses'}), type='caused'), Relationship(source=Node(id='Euro Zone Economy', type='Concept', properties={'name': 'Euro Zone Economy'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='affected'), Relationship(source=Node(id='Euro Zone Economy', type='Concept', properties={'name': 'Euro Zone Economy'}), target=Node(id='Economic Losses', type='Concept', properties={'name': 'Economic Losses'}), type='caused'), Relationship(source=Node(id='British Economy', type='Concept', properties={'name': 'British Economy'}), target=Node(id='Countries', type='Group', properties={'name': 'Countries'}), type='affected'), Relationship(source=Node(id='British Economy', type='Concept', properties={'name': 'British Economy'}), target=Node(id='Economic Losses', type='Concept', properties={'name': 'Economic Losses'}), type='caused'), Relationship(source=Node(id='British Economy', type='Concept', properties={'name': 'British Economy'}), target=Node(id='World War Ii', type='Event', properties={'name': 'World War Ii'}), type='suffered'), Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id=\"China'S Transportation\", type='Concept', properties={'name': \"China'S Transportation\"}), type='affected'), Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id='Tourism', type='Concept', properties={'name': 'Tourism'}), type='affected'), Relationship(source=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), target=Node(id=\"China'S Industries\", type='Group', properties={'name': \"China'S Industries\"}), type='affected'), Relationship(source=Node(id='Chinese Economy', type='Concept', properties={'name': 'Chinese Economy'}), target=Node(id='World Economy', type='Concept', properties={'name': 'World Economy'}), type='affected'), Relationship(source=Node(id='Industry Giants', type='Group', properties={'name': 'Industry Giants'}), target=Node(id='World Economy', type='Concept', properties={'name': 'World Economy'}), type='affected'), Relationship(source=Node(id='Industry Giants', type='Group', properties={'name': 'Industry Giants'}), target=Node(id='Apple Company', type='Company', properties={'name': 'Apple Company'}), type='dominates')] source=Document(page_content=\" epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies. Population decline, massive economic \\nlosses, and national unrest. The U.S. economic \\nrecession seems to be more serious than expected. The \\neuro zone economy has experienced the largest decline \\nin record, and the British economy  has also suffered the \\nlargest decline since World War II. As an exogenous \\nshock, the epidemic will inevitably have a direct impact \\non China's transportation, tourism and other industries. \\nSimilarly, as China is the main source of power to \\npromote world gr owth, once the Chinese economy is \\naffected, the world economy will inevitably be affected. \\nThus, in such an environment where the whole world is \\naffected, to what extent have the industry giants that \\ndominate the world been hit? Let's take the most \\nfamilia r Apple company as\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 13%|█▎        | 3/23 [00:38<05:05, 15.29s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'specializesin': 'consumer electronics, computer software, online services', 'headquarters': 'Cupertino, California', 'founded': 'April 1, 1976', 'wentpublic': 'December 12, 1980', 'marketvaluerecord': '$623.5 billion in 2012', 'largestcompanybymarketcap': 'Yes'})] relationships=[] source=Document(page_content='dominate the world been hit? Let\\'s take the most \\nfamilia r Apple company as an example, and analyze \\nhow much impact this devastating epidemic has brought \\nto Apple’s stocks in several aspects . \\n \\n 2. BACKGROUND INFORM ATION OF \\nAPPLE COMPANY  \\nApple Inc. is an American multinational technology \\ncompany that specializes in consumer electronics, \\ncomputer software, and online services. In it’s \\nheadquartered in Cupertino, California. Apple went \\npublic on December 12, 1980, and set a record of \\n$623.5 billion in market value in 2012. As of June \\n2014, Apple has become the world \\'s largest company by \\nmarket capitalization for three consecutive years. On \\nSeptember 30, 2013, in the Hongmeng Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbec', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 17%|█▋        | 4/23 [00:43<03:29, 11.04s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'marketvalue': 'US$2 trillion', 'rank': '6th', 'revenue': 'largest technology company', 'pcvendorrank': '4th', 'smartphonemanufacturerrank': '4th'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Coca-Cola', type='Company', properties={'name': 'Coca-Cola'}), type='surpassed', properties={'year': '2014'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Google', type='Company', properties={'name': 'Google'}), type='surpassed', properties={'year': '2014'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='marketValueExceeded', properties={'date': 'August 19, 2020', 'value': 'US$2 trillion'})] source=Document(page_content=' Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbecome the world\\'s most valuable brand. In 2014, the \\nApple brand surpassed Goog le to become the world\\'s \\nmost valuable brand. On August 19, 2020 local time, \\nApple\\'s market value exceeded US$2 trillion for the \\nfirst time. Ranked 6th on the Fortune Global 500 list in \\n2021. Apple is the world\\'s largest technology company \\nby revenue and, since January 2021, the world\\'s most \\nvaluable company. As of 2021, Apple is the world\\'s \\nfourth -largest PC vendor by unit sales, and fourth -\\nlargest smartphone manufacturer.  \\n \\nAdvances in Economics, Business and Management Research, volume 203\\nProceedings of the 2021 3rd International Conference on Economic Management and\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 22%|██▏       | 5/23 [00:52<03:04, 10.25s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Cultural Industry (Icemci 2021)', type='Event', properties={'name': 'Cultural Industry (Icemci 2021)'}), Node(id='The Authors', type='Organization', properties={'name': 'The Authors'}), Node(id='Atlantis Press International B.V.', type='Organization', properties={'name': 'Atlantis Press International B.V.'})] relationships=[Relationship(source=Node(id='Cultural Industry (Icemci 2021)', type='Event', properties={'name': 'Cultural Industry (Icemci 2021)'}), target=Node(id='The Authors', type='Organization', properties={'name': 'The Authors'}), type='publishedBy'), Relationship(source=Node(id='Cultural Industry (Icemci 2021)', type='Event', properties={'name': 'Cultural Industry (Icemci 2021)'}), target=Node(id='Atlantis Press International B.V.', type='Organization', properties={'name': 'Atlantis Press International B.V.'}), type='publishedBy')] source=Document(page_content='\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis Press International\\xa0B.V.\\nThis is an open access article distributed under the CC BY-NC 4.0 license -http://creativecommons.org/licenses/by-nc/4.0/. 373', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 26%|██▌       | 6/23 [00:57<02:24,  8.49s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Macroperspective', type='Concept', properties={'description': 'From a macro perspective, the decline in population, the decrease in spending, and the increase in inventories have caused many industries to stagnate. This is bound to bring a huge blow on the global economy to a serious extent.', 'name': 'Macroperspective'}), Node(id='Globaleconomy', type='Concept', properties={'description': 'The global economy is expected to shrink by 3% in 2020 due to the new crown epidemic. The impact will be much more severe than the 2008-2009 financial crisis.', 'name': 'Globaleconomy'}), Node(id='Imf', type='Organization', properties={'description': 'The International Monetary Fund', 'name': 'Imf'}), Node(id='April2020Globaleconomicsurvey', type='Publication', properties={'title': 'April 2020 Global Economic Survey', 'name': 'April2020Globaleconomicsurvey'}), Node(id='Economiccontraction', type='Concept', properties={'description': 'The impact of the epidemic crisis on economic contraction is predicted to be three times that of the financial crisis.', 'name': 'Economiccontraction'}), Node(id='Globaleconomicrecession', type='Event', properties={'startyear': '2007', 'endyear': '2009', 'name': 'Globaleconomicrecession'}), Node(id='Apple', type='Company', properties={'description': \"Most of Apple's components are produced in China.\", 'name': 'Apple'}), Node(id='China', type='Country', properties={'name': 'China'})] relationships=[Relationship(source=Node(id='Macroperspective', type='Concept', properties={'name': 'Macroperspective'}), target=Node(id='Globaleconomy', type='Concept', properties={'name': 'Globaleconomy'}), type='hasImpactOn'), Relationship(source=Node(id='Imf', type='Organization', properties={'name': 'Imf'}), target=Node(id='April2020Globaleconomicsurvey', type='Publication', properties={'name': 'April2020Globaleconomicsurvey'}), type='hasPublished'), Relationship(source=Node(id='Globaleconomy', type='Concept', properties={'name': 'Globaleconomy'}), target=Node(id='Imf', type='Organization', properties={'name': 'Imf'}), type='isStatedBy'), Relationship(source=Node(id='Globaleconomy', type='Concept', properties={'name': 'Globaleconomy'}), target=Node(id='Economiccontraction', type='Concept', properties={'name': 'Economiccontraction'}), type='hasImpactOn'), Relationship(source=Node(id='Globaleconomicrecession', type='Event', properties={'name': 'Globaleconomicrecession'}), target=Node(id='Globaleconomy', type='Concept', properties={'name': 'Globaleconomy'}), type='isRelatedTo'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='China', type='Country', properties={'name': 'China'}), type='isProducedIn')] source=Document(page_content='3. MACRO PERSPECTIVE   \\nFrom a macro perspective, the decline in population, \\nthe decrease in spending, and the increase in inventories \\nhave caused many industries to stagnate. This is bound \\nto bring a huge blow on the global economy to a serious \\nextent. The International Monetary  Fund stated in the \\n\"April 2020 Global Economic Survey\" that due to the \\nnew crown epidemic, the global economy is expected to \\nshrink by 3% in 2020, and the impact will be much \\nmore severe than the 2008 -2009 financial crisis. Some \\nexperts have predicted tha t the impact of the epidemic \\ncrisis on economic contraction will be three times that \\nof the financial crisis. The last global economic \\nrecession began at the end of 2007 and did not fully \\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 30%|███       | 7/23 [01:14<03:01, 11.36s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='China', type='Country', properties={'name': 'China'}), Node(id='Wall Street Journal', type='Publication', properties={'name': 'Wall Street Journal'}), Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='China', type='Country', properties={'name': 'China'}), type='production_location'), Relationship(source=Node(id='China', type='Country', properties={'name': 'China'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='affected_by_epidemic'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Wall Street Journal', type='Publication', properties={'name': 'Wall Street Journal'}), type='reported_by', properties={'date': 'March 24, 2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='trillion_club_member')] source=Document(page_content='\\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so when China is affected by the \\nepidemic and the work is stopped, Apple\\'s products \\ncannot be made at the same time [3]. This will \\ninevitably have a huge impact on Apple. According to \\ninformation reported by the Wall Street Journal on \\nMarch 24, 2020 , Apple\\'s stock price closed down 2.12% \\non Monday, and its market value fell below US$1 trillion to US$981.7 billion. In this way, Apple fell out \\nof the \"trillion club\" of US stocks, of which only \\nMicrosoft was left [7].  \\n4. MICRO PERSPECTIVE  \\nIt is obvious that Apple has been affected by the \\nepidemic in a great extent, however, we still need to \\ntake a look Apple’s', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 35%|███▍      | 8/23 [01:24<02:44, 10.98s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='February 3, 2020', type='Date', properties={'openingprice': '76.07', 'closingprice': '80.01', 'name': 'February 3, 2020'}), Node(id='March 23, 2020', type='Date', properties={'openingprice': '57.02', 'closingprice': '56.09', 'name': 'March 23, 2020'}), Node(id='September 1', type='Date', properties={'openingprice': '132.76', 'closingprice': '134.18', 'name': 'September 1'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='February 3, 2020', type='Date', properties={'name': 'February 3, 2020'}), type='priceChange'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='March 23, 2020', type='Date', properties={'name': 'March 23, 2020'}), type='priceChange'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='September 1', type='Date', properties={'name': 'September 1'}), type='priceChange')] source=Document(page_content=' in a great extent, however, we still need to \\ntake a look Apple’s economic changes in a micro \\nperspective. At the beginning of the epidemic, which is \\nthe start of February, the price started to decline. On \\nFebrua ry 3, 2020, the opening price is 76.07; the \\nclosing price is 80.01. From this point, the closing price \\nstarted to diminish. On March 23, 2020, the opening \\nprice is 57.02, and the closing price is 56.09. The stock \\nprice for this day is the lowest price duri ng epidemic in \\nApple. Then, it started to increase gradually until \\nSeptember 1, this day is also a peak, the opening price \\non September 1 is 132.76 and the closing price is \\n134.18. However, after September 1, the price started to \\ndrop again', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 39%|███▉      | 9/23 [01:34<02:27, 10.53s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='September 18, 2020', type='Date', properties={'name': 'September 18, 2020'}), type='stock_price', properties={'opening_price': '110.40', 'closing_price': '106.84'})] source=Document(page_content=\" \\n134.18. However, after September 1, the price started to \\ndrop again. There is a ver y low price on September 18, \\n2020. The opening price is 110.40, the closing price is \\n106.84.  \\n \\nFigure 1 Apple's stock price  \\n \\n \\nAdvances in Economics, Business and Management Research, volume 203\\n374\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 43%|████▎     | 10/23 [01:38<01:52,  8.64s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Stock', type='Concept', properties={'name': 'Stock'}), Node(id='Announcement', type='Event', properties={'name': 'Announcement'}), Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), Node(id='Iphone 12', type='Product', properties={'name': 'Iphone 12'}), Node(id='Iphone 12 Pro', type='Product', properties={'name': 'Iphone 12 Pro'}), Node(id='Iphone 12 Pro Max', type='Product', properties={'name': 'Iphone 12 Pro Max'}), Node(id='October 14, 2020', type='Date', properties={'name': 'October 14, 2020'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), type='has'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Announcement', type='Event', properties={'name': 'Announcement'}), type='caused'), Relationship(source=Node(id='Announcement', type='Event', properties={'name': 'Announcement'}), target=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), type='delayed'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), type='announced'), Relationship(source=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), target=Node(id='Iphone 12', type='Product', properties={'name': 'Iphone 12'}), type='includes'), Relationship(source=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), target=Node(id='Iphone 12 Pro', type='Product', properties={'name': 'Iphone 12 Pro'}), type='includes'), Relationship(source=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), target=Node(id='Iphone 12 Pro Max', type='Product', properties={'name': 'Iphone 12 Pro Max'}), type='includes'), Relationship(source=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), target=Node(id='October 14, 2020', type='Date', properties={'name': 'October 14, 2020'}), type='peaked on'), Relationship(source=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), target=Node(id='October 12', type='Date', properties={'name': 'October 12'}), type='peaked on'), Relationship(source=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), target=Node(id='New Apple Products', type='Product', properties={'name': 'New Apple Products'}), type='increased due to')] source=Document(page_content=\"Figure 2.  Apple's stock price  \\nThe reasons which caused this drop might be a lot, \\nthe most common answer might be the delay of the \\nannouncement of new Apple Products. A numbers of \\npeople waiting on this day for a long time, because \\nApple supposed to announce the new products like \\niPhone  12, iPhone 12 Pro and iPhone 12 Pro Max, etc. \\nNevertheless, Apple delayed the publish of their new \\nproducts until October 14, 2020. There is a small peak \\nof rising stock price on October 12, which is two days \\nbefore the publish of the new products. The in creasing \\nof Apple stock might because people putted huge \\nexpectations on these new products, and they have been \\nwaited for a long period. This motivation lead them to \\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 48%|████▊     | 11/23 [01:55<02:15, 11.26s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='November 2', type='Date', properties={'name': 'November 2'}), Node(id='December 28', type='Date', properties={'name': 'December 28'}), Node(id='2020', type='Year', properties={'name': '2020'}), Node(id='2021', type='Year', properties={'name': '2021'}), Node(id='February 3', type='Date', properties={'name': 'February 3'}), Node(id='January 26', type='Date', properties={'name': 'January 26'})] relationships=[Relationship(source=Node(id='Buy These Products', type='Action', properties={'name': 'Buy These Products'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='caused'), Relationship(source=Node(id='November 2', type='Date', properties={'name': 'November 2'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='drop', properties={'openingPrice': '109.11', 'closingPrice': '108.77'}), Relationship(source=Node(id='December 28', type='Date', properties={'name': 'December 28'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='peak', properties={'openingPrice': '133.99', 'closingPrice': '136.69', 'highestPrice': '136.69'}), Relationship(source=Node(id='2020', type='Year', properties={'name': '2020'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='increase'), Relationship(source=Node(id='2021', type='Year', properties={'name': '2021'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='increase'), Relationship(source=Node(id='2021', type='Year', properties={'name': '2021'}), target=Node(id='February 3', type='Date', properties={'name': 'February 3'}), type='comparison'), Relationship(source=Node(id='2021', type='Year', properties={'name': '2021'}), target=Node(id='January 26', type='Date', properties={'name': 'January 26'}), type='peak', properties={'openingPrice': '143.6', 'closingPrice': ''})] source=Document(page_content=\"\\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’ stock . On \\nNovember 2, there is a small drop on this day. The \\nopening price is 109.11, and the closing price is 108.77. \\nOn December 28, there is another increasing peak on \\nApple’s stock. The opening price is 133.99, and the \\nclosing price 136.69. This is also the  highest price of \\nApple stock in 2020. After 2020, Apple's stock price \\nwill continue to increase in 2021. This study used two \\nyears of data for comparison, which means it will only \\nuse data from February 3, 2021 and before. So at the \\nbeginning of 2021, App le’s stock price ushered in its \\nfirst peak. On January 26, 2021, the opening price is \\n143.6, and the closing price\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 52%|█████▏    | 12/23 [02:09<02:11, 12.00s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='January 26, 2021', type='Date', properties={'day': '26', 'month': 'January', 'year': '2021', 'name': 'January 26, 2021'}), Node(id='February 3, 2021', type='Date', properties={'day': '3', 'month': 'February', 'year': '2021', 'name': 'February 3, 2021'}), Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), Node(id='Bill Gates', type='Person', properties={'name': 'Bill Gates'}), Node(id='Paul Allen', type='Person', properties={'name': 'Paul Allen'})] relationships=[Relationship(source=Node(id='January 26, 2021', type='Date', properties={'name': 'January 26, 2021'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='stock_price', properties={'opening_price': '143.6', 'closing_price': '143.16'}), Relationship(source=Node(id='February 3, 2021', type='Date', properties={'name': 'February 3, 2021'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='stock_price', properties={'opening_price': '135.76', 'closing_price': '133.94'}), Relationship(source=Node(id='February 3, 2021', type='Date', properties={'name': 'February 3, 2021'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='price_change', properties={'percentage_change': '67.4%'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='competitor'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Bill Gates', type='Person', properties={'name': 'Bill Gates'}), type='founder'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Paul Allen', type='Person', properties={'name': 'Paul Allen'}), type='founder'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Redmond, Washington', type='Location', properties={'name': 'Redmond, Washington'}), type='headquarters')] source=Document(page_content=' On January 26, 2021, the opening price is \\n143.6, and the closing price is 143.16. Later on, there is \\na small drop until February 3, 2021. The opening price \\nis 135.76, and the closing price is 133.94. Comparing \\nthe data at the same day but different year on February \\n3, we can see that the price of Apple’s stock increased \\nby 67.4% in one year.  5. COMPARISON WITH M ICROSOFT \\nCOMPANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Microsof t is an \\nAmerican multinational technology company founded \\nby Bill Gates and Paul Allen on April 4, 1975. The \\ncompany is headquartered in Redmond, Washington \\n(near Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 57%|█████▋    | 13/23 [02:23<02:05, 12.57s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Seattle', type='City', properties={'name': 'Seattle'}), Node(id='Microsoft', type='Company', properties={'famousproducts': 'Windows operating system, Office series software', 'marketvalue': '$2 trillion (as of June 23, 2021)', 'patents': 'More than Apple', 'r&dRatio': 'Higher than Apple', 'r&dInvestment': 'Higher than Apple', 'name': 'Microsoft'}), Node(id='Apple', type='Company', properties={'profit': 'Not specified', 'name': 'Apple'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Seattle', type='City', properties={'name': 'Seattle'}), type='headquarteredIn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Seattle', type='City', properties={'name': 'Seattle'}), type='focusesOn', properties={'areas': 'R&D, manufacturing, licensing, computer software services'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='comparison', properties={'comparisonfactors': 'patents, company environment, R&D ratio, R&D investment'})] source=Document(page_content=\" Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of computer \\nsoftware services. The most famous and best -selling \\nproducts are Windows operating system and Office \\nseries software. It is the world's largest computer \\nsoftware provider and the leader of PC (Personal \\nComputer) software development in the world. On June \\n23, 2021, Microsoft's market value exceeded the $2 \\ntrillion mark. This is the second US company to enter \\nafter Apple's breakthrough of $2 trillion. In 2019, the \\nmarket value of Microsoft reached US$1 trillion for the \\nfirst time, 33 years after the original Mi crosoft IPO. \\nFrom 1 trillion to 2 trillion, Microsoft only took about 2 \\nyears. Comparing Microsoft and Apple, Microsoft has \\nmore patents, company environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 61%|██████    | 14/23 [02:32<01:44, 11.62s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Environment', type='Concept', properties={'name': 'Environment'}), Node(id='R&D Ratio', type='Concept', properties={'name': 'R&D Ratio'}), Node(id='R&D Investment', type='Concept', properties={'name': 'R&D Investment'}), Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), Node(id='Profit', type='Concept', properties={'name': 'Profit'}), Node(id='Profit Margin', type='Concept', properties={'name': 'Profit Margin'}), Node(id='Revenue', type='Concept', properties={'name': 'Revenue'}), Node(id='Market Value', type='Concept', properties={'name': 'Market Value'}), Node(id='Enterprise-Level Market', type='Concept', properties={'name': 'Enterprise-Level Market'}), Node(id='Customers', type='Concept', properties={'name': 'Customers'}), Node(id='Epidemic', type='Concept', properties={'name': 'Epidemic'}), Node(id='Employees', type='Concept', properties={'name': 'Employees'}), Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'})] relationships=[Relationship(source=Node(id='Environment', type='Concept', properties={'name': 'Environment'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='has'), Relationship(source=Node(id='Environment', type='Concept', properties={'name': 'Environment'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='has'), Relationship(source=Node(id='R&D Ratio', type='Concept', properties={'name': 'R&D Ratio'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='has'), Relationship(source=Node(id='R&D Ratio', type='Concept', properties={'name': 'R&D Ratio'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='has'), Relationship(source=Node(id='R&D Investment', type='Concept', properties={'name': 'R&D Investment'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='has'), Relationship(source=Node(id='R&D Investment', type='Concept', properties={'name': 'R&D Investment'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='has'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Profit', type='Concept', properties={'name': 'Profit'}), type='has'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Profit Margin', type='Concept', properties={'name': 'Profit Margin'}), type='has'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Revenue', type='Concept', properties={'name': 'Revenue'}), type='has'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Market Value', type='Concept', properties={'name': 'Market Value'}), type='has'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Profit', type='Concept', properties={'name': 'Profit'}), type='has'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Profit Margin', type='Concept', properties={'name': 'Profit Margin'}), type='has'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Revenue', type='Concept', properties={'name': 'Revenue'}), type='has'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Market Value', type='Concept', properties={'name': 'Market Value'}), type='has'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Enterprise-Level Market', type='Concept', properties={'name': 'Enterprise-Level Market'}), type='has'), Relationship(source=Node(id='Enterprise-Level Market', type='Concept', properties={'name': 'Enterprise-Level Market'}), target=Node(id='Profit Margin', type='Concept', properties={'name': 'Profit Margin'}), type='has'), Relationship(source=Node(id='Enterprise-Level Market', type='Concept', properties={'name': 'Enterprise-Level Market'}), target=Node(id='Customers', type='Concept', properties={'name': 'Customers'}), type='has'), Relationship(source=Node(id='Epidemic', type='Concept', properties={'name': 'Epidemic'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='has'), Relationship(source=Node(id='Employees', type='Concept', properties={'name': 'Employees'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='has'), Relationship(source=Node(id='Epidemic', type='Concept', properties={'name': 'Epidemic'}), target=Node(id='Stock Price', type='Concept', properties={'name': 'Stock Price'}), type='has')] source=Document(page_content=\" environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit, profit \\nmargin, revenue, etc. are more t han that of Microsoft. \\nThis is why Apple’s market value can break 2 trillion \\nearlier than Microsoft. On the two items of profit and \\nprofit margin, Microsoft's performance is not good. \\nAfter all, it is an enterprise -level market. If the profit \\nmargin is too  high, customers are easy to lose.  \\nDuring the epidemic, Microsoft let their employees \\nto work at home, Its stock price has also changed more \\nor less with the epidemic flow. In March 6, 2020 report, \\nAdvances in Economics, Business and Management Research, volume 203\\n375\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 65%|██████▌   | 15/23 [03:02<02:17, 17.17s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), Node(id='Monday', type='Date', properties={'name': 'Monday'}), Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), Node(id='March 23', type='Date', properties={'name': 'March 23'}), Node(id='March 16', type='Date', properties={'name': 'March 16'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Monday', type='Date', properties={'name': 'Monday'}), type='stock_price_change', properties={'percentage_change': '-14.74%'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), type='stock_price_change', properties={'percentage_change': '-15.6%'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), type='stock_price_change', properties={'start_decrease': 'true'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowest_price', properties={'price': '135.42'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowest_price', properties={'price': '140.0'})] source=Document(page_content=\"Microsoft's stock price plummeted 14.74% on Monday, \\nthe la rgest single -day drop since April 24, 2000. At that \\ntime, Microsoft's stock price fell by 15.6%. In the past \\nmonth, Microsoft's stock price has fallen by 27%, and \\nthe Dow has fallen by 31% [5].  \\nIn a micro perspective, during epidemic time, \\nMicrosoft’s stoc k start decrease since February 10, \\n2020. At the time when Apple had their its lowest price \\non March 23, Microsoft also having a bad situation, but \\nthe lowest price of Microsoft price is on March 16. The \\nopening price on that day is 140.0, the closing pric e is \\n135.42. Even thought the stock price of Microsoft is \\nmuch higher than Apple, but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\n\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 70%|██████▉   | 16/23 [03:15<01:51, 15.86s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'marketvalue': 'higher than Microsoft', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='volumeComparison', properties={'relation': 'higher than'})] source=Document(page_content=\" but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\nMicrosoft. It is because Apple's market value is higher \\nthan Microsoft.  \\n6. OVERALL TREND  \\nFor Apple, th e epidemic only affected it at the \\nbeginning, but it took only four months for Apple to \\nreturn to its previous normal stock price. It can be seen \\nthat the true hidden strength behind Apple can enable \\nApple. Recovered in such a short time. The overall \\nsitua tion of Apple's stock price continued to rise. It only \\nfell sharply between February and June, when the \\nepidemic first began, but it quickly returned to its \\noriginal state. During the period from August to \\nNovember, the impact of Apple's new products rose \\nfirst and then fell back to normal levels. There was also \\na peak in early 2021, and then\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 74%|███████▍  | 17/23 [03:19<01:13, 12.20s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'stockincrease': '67.4%', 'highestvalue': 'December', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'highestvalue': 'September', 'name': 'Microsoft'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='similarTo')] source=Document(page_content=\" then fell back to normal levels. There was also \\na peak in early 2021, and then it returned to normal \\nlevels. The overall level of Apple's stock increased by \\n67.4% over the same period.  \\nFor Microsoft, his situation is actually similar to that \\nof the same type of Apple. At the beginning of the \\nepidemic, there was a huge decline from February to \\nMarch, but it was basically fully restored to the \\nprevious level before June. Like Apple, it took just four \\nmonths to solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot \\nbe underestimated. Microsoft's overall trend continues \\nto rise. However, unlike Apple, the highest value of \\nApple's stock is in December, which is the end of 2020, \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 78%|███████▊  | 18/23 [03:23<00:48,  9.74s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), Node(id='September', type='Date', properties={'name': 'September'}), Node(id='Stock', type='Concept', properties={'name': 'Stock'}), Node(id='Apple', type='Company', properties={'name': 'Apple'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), type='has'), Relationship(source=Node(id='September', type='Date', properties={'name': 'September'}), target=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), type='highest value in'), Relationship(source=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='compared to'), Relationship(source=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='compared to'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='number of transactions greater than'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), type='total trading volume similar to'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Stock', type='Concept', properties={'name': 'Stock'}), type='total trading volume similar to'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='total trading volume sometimes higher than'), Relationship(source=Node(id='Pandemic', type='Concept', properties={'name': 'Pandemic'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='did not bring irreparable blow to')] source=Document(page_content=\" \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September, the stock declined \\nslightly, but it only fell to a normal level, and then \\nslowly climbed up.  \\n7. CONCLUSION  \\nComparing Apple's stock price and Microsoft's \\nstock price, we can find that Microsoft's stock price is \\nmuch h igher than Apple's, but when we compare their \\nnumber of transactions, we find that Apple's number of \\ntransactions is many times greater than that of \\nMicrosoft. This has also led to the fact that the total \\ntrading volume of Apple stock and Microsoft stock i s similar, and sometimes Apple is even higher than \\nMicrosoft.  \\nTo conclude, the pandemic did not bring an \\nirreparable blow to Apple. Instead, it only took it four \\nmonths to restore its stock to its original value\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 83%|████████▎ | 19/23 [03:36<00:43, 10.87s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'})] relationships=[] source=Document(page_content=\" Apple. Instead, it only took it four \\nmonths to restore its stock to its original value, or even \\nrise. This is enough to show that Apple's foundation is \\nstable and there are excellent strategies to enable them \\nto recover their losses in time when they faced strong \\nimpacts. In general, Apple's stock only declined during \\nthe most severe period of the pandemic, and remained \\nat a stable value for the rest of the time, and there was \\nalso a phenomenon of continuous ri se. \\nREFERENCES  \\n[1] Yahoo is now a part of Verizon Media. (n.d.). \\nYahoo. Retrieved August 29, 2021, from \\nhttps://finance.yahoo.com/quote/AAPL/chart? \\\\ \\n[2] Ziemba, W. T. (2020, June 21). The COVID -19 \\nCrash in\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 87%|████████▋ | 20/23 [03:38<00:24,  8.14s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='W. T.', type='Author', properties={'name': 'W. T.'}), Node(id='Ziemba', type='Journal', properties={'title': 'The COVID-19 Crash in the US Stock Market', 'url': 'https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3632410', 'name': 'Ziemba'}), Node(id='B. Yan', type='Author', properties={'name': 'B. Yan'}), Node(id='Yan', type='Journal', properties={'title': 'Analysis of the Effect of COVID-19 on the Stock Market and Investing Strategies', 'url': 'https://papers.ssrn.com/sol3/Papers.cfm?abstract_id=3563380', 'name': 'Yan'}), Node(id='J. A. C. Camba', type='Author', properties={'name': 'J. A. C. Camba'}), Node(id='The Journal Of Asian Finance', type='Journal', properties={'title': 'The Effects of Restrictions in Economic Activity on the Spread of COVID-19 in the Philippines: Insights from Apple and Google Mobility Indicators', 'name': 'The Journal Of Asian Finance'})] relationships=[] source=Document(page_content=', W. T. (2020, June 21). The COVID -19 \\nCrash in the US Stock Market. Ziemba. \\nhttps://papers.ssrn.com/sol3/papers.cfm?abstract_i\\nd=3632410  \\n[3] Yan, B. (2020, March 28). Anal ysis of the Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies. Yan. \\nhttps://papers.ssrn.com/sol3/Papers.cfm?abstract_i\\nd=3563380  \\n[4] Camba, J. A. C. (2020). The Effect s of Restrictions \\nin Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance,', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 91%|█████████▏| 21/23 [03:45<00:15,  7.87s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'source': 'The Journal of Asian Finance, Economics and Business | Korea Science', 'link': 'https://www.koreascience.or.kr/article/JAKO202034651879125.page', 'name': 'Insights From Apple And Google Mobility Indicators'}), Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'author': 'Shivaani, M. V.', 'source': 'Journal of Emerging Technologies in Accounting', 'link': 'https://meridian.allenpress.com/jeta/article-abstract/doi/10.2308/JETA-2020-045/464597/Comparing-Apple-to-Amazon-Just-a-Matter-of-Words', 'name': 'Comparing Apple To Amazon: Just A Matter Of Words'})] relationships=[Relationship(source=Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), target=Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'name': 'Insights From Apple And Google Mobility Indicators'}), type='insights'), Relationship(source=Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), target=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), type='comparison')] source=Document(page_content='in Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance, \\nEconomics and Business | Korea Science. Camba. \\nhttps://www.koreascience.or.kr/article/JAKO2020\\n34651879125.page  \\n[5] Shivaani, M. V. (n.d.). Comparing Apple to \\nAmazon: Just a Matter of Words in Machine \\nLearning World | Journal of Emerging \\nTechnologies in Accounting. Shivaani. Retrieved \\nAugust 29, 2021, from \\nhttps://meridian.allenpress.com/jeta/article -\\nabstract/doi/10.2 308/JETA -2020 -\\n045/464597/Comparing -Apple -to-Amazon -Just-a-\\nMatter -of-Words ', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 96%|█████████▌| 22/23 [03:57<00:09,  9.00s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'ticker': 'AAPL', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'ticker': 'MSFT', 'name': 'Microsoft'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='competitor')] source=Document(page_content='aring -Apple -to-Amazon -Just-a-\\nMatter -of-Words  \\n[6] Apple (AAPL) Vs Microsoft (MSFT): Which Is A \\nBetter Tech Stock To Buy Right Now?, 28 Jan. \\n2021, www.nasdaq.com/articles/apple -aapl-vs-\\nmicrosoft -msft%3A -which -is-a-better -tech-stock-\\nto-buy-right -now-2021 -01-28. \\n[7] Osipovich Alexander. “Apple’s market capitalisation \\nhas fallen below trillion, and Microsoft is the only \\nremaining U.S. company in the trillion -dollar \\nclub. ” Wall Street News, 24 Mar. 2020, \\ncn.wsj.com/articles /  \\nAdvances in Economics, Business and Management Research, volume 203\\n376', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 23/23 [04:01<00:00, 10.52s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes list : 111\n",
      "Distinct nodes : 80\n",
      "Relationships : 113\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "\n",
    "distinct_nodes = set()\n",
    "nodes = []\n",
    "relations = []\n",
    "\n",
    "for i, chunk in tqdm(enumerate(chunks), total=len(chunks)):\n",
    "    graph_document=extract_and_store_graph(chunk)\n",
    "    \n",
    "    #Get distinct nodes\n",
    "    for node in graph_document.nodes :\n",
    "        nodes.append(node.id)\n",
    "        distinct_nodes.add(node.id)\n",
    "        \n",
    "    \n",
    "    #Get all relations   \n",
    "    for relation in graph_document.relationships :\n",
    "        relations.append(relation.type)\n",
    "        \n",
    "print(\"nodes list :\", len(nodes))\n",
    "print(\"Distinct nodes :\",len(distinct_nodes))\n",
    "print(\"Relationships :\",len(relations))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbc558bf",
   "metadata": {},
   "source": [
    "# With 500 chunk size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "9f13779e",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/10 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Covid-19', type='Event', properties={'name': 'Covid-19'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Covid-19', type='Event', properties={'name': 'Covid-19'}), type='stock_price_changes', properties={'description': \"During the pandemic, Apple's stock price experienced fluctuations.\"})] source=Document(page_content=\"The Changes of Apple’s Stock Price During the \\nPandemic  \\nWanting Sun1,* \\n1WendySun, Kinglee High School, Zheng Zhou, He Nan, China, 450000  \\n*Corresponding author. Email:  wendysun040718@163.com  \\nABSTRACT  \\nDuring the epidemic, the economies of various countries, including many large companies, were subject to very large \\nfluctuations and impacts. Therefore, this article will explore the ups and downs of Apple's stock price duri ng the \\nepidemic. At different points in time and severity, Apple's stock price has risen and fallen. By observing the data on \\nYahoo, we can summarize Apple's stock price changes during this period. At the beginning of the epidemic, the global \\neconomy has b een damaged, so Apple is no exception. So at the beginning of the epidemic, Apple's stock price fell \\nsharply. But later, because Apple had a strong overall strength and a good foundation, it only took three months to \\nsolve the impact of the epidemic. Later , when the epidemic returned to a serious situation, Apple's stock price was \\nimplicated and fell slightly, but within a few weeks the stock price decline was resolved and returned to normal levels, \\nand even steadily increased. Because Apple has been consta ntly launching new products, the epidemic will not have a \\nvery large impact on Apple's stock price.  \\nKeywords:  Apple, stock price, COVID -19  \\n1. INTRODUCTION  \\nAs we know, the outbreak of the epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies. Population decline, massive economic \\nlosses, and national unrest. The U.S. economic \\nrecession seems to be more serious than expected. The \\neuro zone economy has experienced the largest decline \\nin record, and the British economy  has also suffered the \\nlargest decline since World War II. As an exogenous \\nshock, the epidemic will inevitably have a direct impact \\non China's transportation, tourism and other industries. \\nSimilarly, as China is the main source of power to \\npromote world gr owth, once the Chinese economy\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 10%|█         | 1/10 [00:04<00:44,  4.93s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'specializesin': 'consumer electronics, computer software, online services', 'headquarters': 'Cupertino, California', 'founded': 'April 1, 1976', 'marketvalue': '$623.5 billion (2012)', 'largestcompanybymarketcap': 'Yes', 'mostvaluablebrand': 'Yes', 'marketvalue2020': '$2 trillion', 'fortuneglobal500rank': '6th (2021)', 'largesttechcompanybyrevenue': 'Yes', 'largestpcvendor': '4th (2021)', 'largestsmartphonemanufacturer': '4th (2021)'})] relationships=[] source=Document(page_content=' is the main source of power to \\npromote world gr owth, once the Chinese economy is \\naffected, the world economy will inevitably be affected. \\nThus, in such an environment where the whole world is \\naffected, to what extent have the industry giants that \\ndominate the world been hit? Let\\'s take the most \\nfamilia r Apple company as an example, and analyze \\nhow much impact this devastating epidemic has brought \\nto Apple’s stocks in several aspects . \\n \\n 2. BACKGROUND INFORM ATION OF \\nAPPLE COMPANY  \\nApple Inc. is an American multinational technology \\ncompany that specializes in consumer electronics, \\ncomputer software, and online services. In it’s \\nheadquartered in Cupertino, California. Apple went \\npublic on December 12, 1980, and set a record of \\n$623.5 billion in market value in 2012. As of June \\n2014, Apple has become the world \\'s largest company by \\nmarket capitalization for three consecutive years. On \\nSeptember 30, 2013, in the Hongmeng Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbecome the world\\'s most valuable brand. In 2014, the \\nApple brand surpassed Goog le to become the world\\'s \\nmost valuable brand. On August 19, 2020 local time, \\nApple\\'s market value exceeded US$2 trillion for the \\nfirst time. Ranked 6th on the Fortune Global 500 list in \\n2021. Apple is the world\\'s largest technology company \\nby revenue and, since January 2021, the world\\'s most \\nvaluable company. As of 2021, Apple is the world\\'s \\nfourth -largest PC vendor by unit sales, and fourth -\\nlargest smartphone manufacturer.  \\n \\nAdvances in Economics, Business and Management Research, volume 203\\nProceedings of the 2021 3rd International Conference on Economic Management and\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis Press International\\xa0B.V.\\nThis is an open access article distributed under the CC BY-NC 4.0 license -http://creativecommons.org/licenses/by-nc/4.0/. 373', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 20%|██        | 2/10 [00:13<00:54,  6.81s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Macro_Perspective', type='Perspective', properties={'description': 'From a macro perspective, the decline in population, the decrease in spending, and the increase in inventories have caused many industries to stagnate. This is bound to bring a huge blow on the global economy to a serious extent.', 'name': 'Macro_Perspective'}), Node(id='Global_Economy', type='Concept', properties={'description': 'The global economy is expected to shrink by 3% in 2020 due to the new crown epidemic. The impact will be much more severe than the 2008-2009 financial crisis.', 'name': 'Global_Economy'}), Node(id='International_Monetary_Fund', type='Organization', properties={'description': \"The International Monetary Fund stated in the 'April 2020 Global Economic Survey' that the global economy is expected to shrink by 3% in 2020 due to the new crown epidemic.\", 'name': 'International_Monetary_Fund'}), Node(id='Epidemic_Impact', type='Concept', properties={'description': 'The impact of the epidemic crisis on economic contraction is predicted to be three times that of the financial crisis.', 'name': 'Epidemic_Impact'}), Node(id='Global_Recession', type='Event', properties={'description': 'The last global economic recession began at the end of 2007 and did not fully recover until June 2009.', 'name': 'Global_Recession'}), Node(id='Apple', type='Company', properties={'description': \"Apple's components are produced in China, so when China is affected by the epidemic and the work is stopped, Apple's products cannot be made at the same time.\", 'name': 'Apple'}), Node(id='Wall_Street_Journal', type='Publication', properties={'description': \"According to information reported by the Wall Street Journal on March 24, 2020, Apple's stock price closed down 2.12% on Monday, and its market value fell below US$1 trillion to US$981.7 billion.\", 'name': 'Wall_Street_Journal'}), Node(id='Micro_Perspective', type='Perspective', properties={'description': \"Apple's economic changes in a micro perspective during the epidemic.\", 'name': 'Micro_Perspective'})] relationships=[Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Global_Economy', type='Concept', properties={'name': 'Global_Economy'}), type='has'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='International_Monetary_Fund', type='Organization', properties={'name': 'International_Monetary_Fund'}), type='cited_by'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Epidemic_Impact', type='Concept', properties={'name': 'Epidemic_Impact'}), type='has'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Global_Recession', type='Event', properties={'name': 'Global_Recession'}), type='compared_to'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='affected_by'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Wall_Street_Journal', type='Publication', properties={'name': 'Wall_Street_Journal'}), type='reported_by'), Relationship(source=Node(id='Micro_Perspective', type='Perspective', properties={'name': 'Micro_Perspective'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='focused_on')] source=Document(page_content='3. MACRO PERSPECTIVE   \\nFrom a macro perspective, the decline in population, \\nthe decrease in spending, and the increase in inventories \\nhave caused many industries to stagnate. This is bound \\nto bring a huge blow on the global economy to a serious \\nextent. The International Monetary  Fund stated in the \\n\"April 2020 Global Economic Survey\" that due to the \\nnew crown epidemic, the global economy is expected to \\nshrink by 3% in 2020, and the impact will be much \\nmore severe than the 2008 -2009 financial crisis. Some \\nexperts have predicted tha t the impact of the epidemic \\ncrisis on economic contraction will be three times that \\nof the financial crisis. The last global economic \\nrecession began at the end of 2007 and did not fully \\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so when China is affected by the \\nepidemic and the work is stopped, Apple\\'s products \\ncannot be made at the same time [3]. This will \\ninevitably have a huge impact on Apple. According to \\ninformation reported by the Wall Street Journal on \\nMarch 24, 2020 , Apple\\'s stock price closed down 2.12% \\non Monday, and its market value fell below US$1 trillion to US$981.7 billion. In this way, Apple fell out \\nof the \"trillion club\" of US stocks, of which only \\nMicrosoft was left [7].  \\n4. MICRO PERSPECTIVE  \\nIt is obvious that Apple has been affected by the \\nepidemic in a great extent, however, we still need to \\ntake a look Apple’s economic changes in a micro \\nperspective. At the beginning of the epidemic, which is \\nthe start of February, the price started to decline. On \\nFebrua ry 3, 2020, the opening price is 76.07; the \\nclosing price is 80.01. From this point, the closing price \\nstarted to diminish. On March 23, 2020, the opening \\nprice is 57.02, and the closing price is 56.09. The stock \\nprice for this day is the lowest price duri ng epidemic in ', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 30%|███       | 3/10 [00:32<01:29, 12.73s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='09', type='Date', properties={'name': '09'}), Node(id='September 1', type='Date', properties={'name': 'September 1'}), Node(id='September 18, 2020', type='Date', properties={'name': 'September 18, 2020'})] relationships=[Relationship(source=Node(id='09', type='Date', properties={'name': '09'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='lowest_price_during_epidemic'), Relationship(source=Node(id='September 1', type='Date', properties={'name': 'September 1'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='peak', properties={'opening_price': '132.76', 'closing_price': '134.18'}), Relationship(source=Node(id='September 18, 2020', type='Date', properties={'name': 'September 18, 2020'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='very_low_price', properties={'opening_price': '110.40', 'closing_price': '106.84'})] source=Document(page_content=\"09. The stock \\nprice for this day is the lowest price duri ng epidemic in \\nApple. Then, it started to increase gradually until \\nSeptember 1, this day is also a peak, the opening price \\non September 1 is 132.76 and the closing price is \\n134.18. However, after September 1, the price started to \\ndrop again. There is a ver y low price on September 18, \\n2020. The opening price is 110.40, the closing price is \\n106.84.  \\n \\nFigure 1 Apple's stock price  \\n \\n \\nAdvances in Economics, Business and Management Research, volume 203\\n374\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 40%|████      | 4/10 [00:39<01:02, 10.50s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Iphone 12', type='Product', properties={'name': 'Iphone 12'}), Node(id='Iphone 12 Pro', type='Product', properties={'name': 'Iphone 12 Pro'}), Node(id='Iphone 12 Pro Max', type='Product', properties={'name': 'Iphone 12 Pro Max'})] relationships=[Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Iphone 12', type='Product', properties={'name': 'Iphone 12'}), type='announces'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Iphone 12 Pro', type='Product', properties={'name': 'Iphone 12 Pro'}), type='announces'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Iphone 12 Pro Max', type='Product', properties={'name': 'Iphone 12 Pro Max'}), type='announces'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='October 14, 2020', type='Date', properties={'name': 'October 14, 2020'}), type='delays announcement'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='October 12, 2020', type='Date', properties={'name': 'October 12, 2020'}), type='rise in stock price', properties={'openingPrice': '109.11', 'closingPrice': '108.77'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='December 28, 2020', type='Date', properties={'name': 'December 28, 2020'}), type='rise in stock price', properties={'openingPrice': '133.99', 'closingPrice': '136.69'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='2021', type='Year', properties={'name': '2021'}), type='continues to increase stock price'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='January 26, 2021', type='Date', properties={'name': 'January 26, 2021'}), type='drop in stock price', properties={'openingPrice': '143.6', 'closingPrice': '143.16'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='February 3, 2021', type='Date', properties={'name': 'February 3, 2021'}), type='drop in stock price', properties={'openingPrice': '135.76', 'closingPrice': '133.94'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='February 3, 2020', type='Date', properties={'name': 'February 3, 2020'}), type='comparison', properties={'priceIncreasePercentage': '67.4%'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='competes with')] source=Document(page_content=\"Figure 2.  Apple's stock price  \\nThe reasons which caused this drop might be a lot, \\nthe most common answer might be the delay of the \\nannouncement of new Apple Products. A numbers of \\npeople waiting on this day for a long time, because \\nApple supposed to announce the new products like \\niPhone  12, iPhone 12 Pro and iPhone 12 Pro Max, etc. \\nNevertheless, Apple delayed the publish of their new \\nproducts until October 14, 2020. There is a small peak \\nof rising stock price on October 12, which is two days \\nbefore the publish of the new products. The in creasing \\nof Apple stock might because people putted huge \\nexpectations on these new products, and they have been \\nwaited for a long period. This motivation lead them to \\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’ stock . On \\nNovember 2, there is a small drop on this day. The \\nopening price is 109.11, and the closing price is 108.77. \\nOn December 28, there is another increasing peak on \\nApple’s stock. The opening price is 133.99, and the \\nclosing price 136.69. This is also the  highest price of \\nApple stock in 2020. After 2020, Apple's stock price \\nwill continue to increase in 2021. This study used two \\nyears of data for comparison, which means it will only \\nuse data from February 3, 2021 and before. So at the \\nbeginning of 2021, App le’s stock price ushered in its \\nfirst peak. On January 26, 2021, the opening price is \\n143.6, and the closing price is 143.16. Later on, there is \\na small drop until February 3, 2021. The opening price \\nis 135.76, and the closing price is 133.94. Comparing \\nthe data at the same day but different year on February \\n3, we can see that the price of Apple’s stock increased \\nby 67.4% in one year.  5. COMPARISON WITH M ICROSOFT \\nCOMPANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Micro\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 50%|█████     | 5/10 [01:00<01:10, 14.19s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'foundedby': 'Bill Gates, Paul Allen', 'foundedon': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'focus': 'R&D, manufacturing, licensing, computer software services', 'famousproducts': 'Windows operating system, Office series software', 'marketvalue': '$2 trillion (as of June 23, 2021)', 'patents': 'More than Apple', 'r&dratio': 'Higher than Apple', 'r&dinvestment': 'Higher than Apple', 'name': 'Microsoft'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='competitor')] source=Document(page_content=\"ANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Microsof t is an \\nAmerican multinational technology company founded \\nby Bill Gates and Paul Allen on April 4, 1975. The \\ncompany is headquartered in Redmond, Washington \\n(near Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of computer \\nsoftware services. The most famous and best -selling \\nproducts are Windows operating system and Office \\nseries software. It is the world's largest computer \\nsoftware provider and the leader of PC (Personal \\nComputer) software development in the world. On June \\n23, 2021, Microsoft's market value exceeded the $2 \\ntrillion mark. This is the second US company to enter \\nafter Apple's breakthrough of $2 trillion. In 2019, the \\nmarket value of Microsoft reached US$1 trillion for the \\nfirst time, 33 years after the original Mi crosoft IPO. \\nFrom 1 trillion to 2 trillion, Microsoft only took about 2 \\nyears. Comparing Microsoft and Apple, Microsoft has \\nmore patents, company environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit, profit \\nmargin, revenue, etc. are more t han that of Microsoft. \\nThis is why Apple’s market value can break 2 trillion \\nearlier than Microsoft. On the two items of profit and \\nprofit margin, Microsoft's performance is not good. \\nAfter all, it is an enterprise -level market. If the profit \\nmargin is too  high, customers are easy to lose.  \\nDuring the epidemic, Microsoft let their employees \\nto work at home, Its stock price has also changed more \\nor less with the epidemic flow. In March 6, 2020 report, \\nAdvances in Economics, Business and Management Research, volume 203\\n375\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 60%|██████    | 6/10 [01:06<00:45, 11.44s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'stockpriceplummeted': '14.74%', 'largestsingledaydrop': 'April 24, 2000', 'stockpricefallen': '27%', 'name': 'Microsoft'}), Node(id='Monday', type='Day', properties={'name': 'Monday'}), Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), Node(id='March 23', type='Date', properties={'name': 'March 23'}), Node(id='March 16', type='Date', properties={'openingprice': '140.0', 'closingprice': '135.42', 'name': 'March 16'}), Node(id='Apple', type='Company', properties={'lowestprice': 'March 23', 'volume': 'higher than Microsoft', 'marketvalue': 'higher than Microsoft', 'name': 'Apple'}), Node(id=\"Microsoft'S Stock\", type='Stock', properties={'name': \"Microsoft'S Stock\"}), Node(id=\"Apple'S Stock\", type='Stock', properties={'name': \"Apple'S Stock\"}), Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), Node(id='February', type='Month', properties={'name': 'February'}), Node(id='June', type='Month', properties={'name': 'June'}), Node(id='August', type='Month', properties={'name': 'August'}), Node(id='November', type='Month', properties={'name': 'November'}), Node(id='2021', type='Year', properties={'name': '2021'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Stockpriceplummeted', type='Attribute', properties={'name': 'Stockpriceplummeted'}), type='hasAttribute'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Largestsingledaydrop', type='Attribute', properties={'name': 'Largestsingledaydrop'}), type='hasAttribute'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Stockpricefallen', type='Attribute', properties={'name': 'Stockpricefallen'}), type='hasAttribute'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Monday', type='Day', properties={'name': 'Monday'}), type='stockPricePlummetedOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), type='largestSingleDayDropOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Stockpricefallen', type='Attribute', properties={'name': 'Stockpricefallen'}), type='hasAttribute'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), type='stockDecreaseStartedOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowestPriceOn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='volumeHigherThan'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='marketValueHigherThan'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), type='affectedBy'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Epidemic', type='Event', properties={'name': 'Epidemic'}), type='affectedBy'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February', type='Month', properties={'name': 'February'}), type='stockDecreaseStartedIn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='June', type='Month', properties={'name': 'June'}), type='fullyRestoredBefore'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='June', type='Month', properties={'name': 'June'}), type='fullyRestoredBefore'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='August', type='Month', properties={'name': 'August'}), type='impactOfNewProducts'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='November', type='Month', properties={'name': 'November'}), type='impactOfNewProducts'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='2021', type='Year', properties={'name': '2021'}), type='peakIn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='2021', type='Year', properties={'name': '2021'}), type='peakIn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='67.4%', type='Attribute', properties={'name': '67.4%'}), type='overallLevelIncreasedBy')] source=Document(page_content=\"Microsoft's stock price plummeted 14.74% on Monday, \\nthe la rgest single -day drop since April 24, 2000. At that \\ntime, Microsoft's stock price fell by 15.6%. In the past \\nmonth, Microsoft's stock price has fallen by 27%, and \\nthe Dow has fallen by 31% [5].  \\nIn a micro perspective, during epidemic time, \\nMicrosoft’s stoc k start decrease since February 10, \\n2020. At the time when Apple had their its lowest price \\non March 23, Microsoft also having a bad situation, but \\nthe lowest price of Microsoft price is on March 16. The \\nopening price on that day is 140.0, the closing pric e is \\n135.42. Even thought the stock price of Microsoft is \\nmuch higher than Apple, but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\nMicrosoft. It is because Apple's market value is higher \\nthan Microsoft.  \\n6. OVERALL TREND  \\nFor Apple, th e epidemic only affected it at the \\nbeginning, but it took only four months for Apple to \\nreturn to its previous normal stock price. It can be seen \\nthat the true hidden strength behind Apple can enable \\nApple. Recovered in such a short time. The overall \\nsitua tion of Apple's stock price continued to rise. It only \\nfell sharply between February and June, when the \\nepidemic first began, but it quickly returned to its \\noriginal state. During the period from August to \\nNovember, the impact of Apple's new products rose \\nfirst and then fell back to normal levels. There was also \\na peak in early 2021, and then it returned to normal \\nlevels. The overall level of Apple's stock increased by \\n67.4% over the same period.  \\nFor Microsoft, his situation is actually similar to that \\nof the same type of Apple. At the beginning of the \\nepidemic, there was a huge decline from February to \\nMarch, but it was basically fully restored to the \\nprevious level before June. Like Apple, it took just four \\nmonths to solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 70%|███████   | 7/10 [01:35<00:50, 16.96s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), Node(id='Apple', type='Company', properties={'name': 'Apple'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='comparison', properties={'observation': \"Microsoft's stock price is much higher than Apple's.\"}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='comparison', properties={'observation': \"Apple's number of transactions is many times greater than Microsoft's.\"}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='comparison', properties={'observation': 'The total trading volume of Apple stock and Microsoft stock is similar.'})] source=Document(page_content=\" solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot \\nbe underestimated. Microsoft's overall trend continues \\nto rise. However, unlike Apple, the highest value of \\nApple's stock is in December, which is the end of 2020, \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September, the stock declined \\nslightly, but it only fell to a normal level, and then \\nslowly climbed up.  \\n7. CONCLUSION  \\nComparing Apple's stock price and Microsoft's \\nstock price, we can find that Microsoft's stock price is \\nmuch h igher than Apple's, but when we compare their \\nnumber of transactions, we find that Apple's number of \\ntransactions is many times greater than that of \\nMicrosoft. This has also led to the fact that the total \\ntrading volume of Apple stock and Microsoft stock i s similar, and sometimes Apple is even higher than \\nMicrosoft.  \\nTo conclude, the pandemic did not bring an \\nirreparable blow to Apple. Instead, it only took it four \\nmonths to restore its stock to its original value, or even \\nrise. This is enough to show that Apple's foundation is \\nstable and there are excellent strategies to enable them \\nto recover their losses in time when they faced strong \\nimpacts. In general, Apple's stock only declined during \\nthe most severe period of the pandemic, and remained \\nat a stable value for the rest of the time, and there was \\nalso a phenomenon of continuous ri se. \\nREFERENCES  \\n[1] Yahoo is now a part of Verizon Media. (n.d.). \\nYahoo. Retrieved August 29, 2021, from \\nhttps://finance.yahoo.com/quote/AAPL/chart? \\\\ \\n[2] Ziemba, W. T. (2020, June 21). The COVID -19 \\nCrash in the US Stock Market. Ziemba. \\nhttps://papers.ssrn.com/sol3/papers.cfm?abstract_i\\nd=3632410  \\n[3] Yan, B. (2020, March 28). Anal ysis of the\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 80%|████████  | 8/10 [01:42<00:27, 13.82s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Yan', type='Person', properties={'name': 'Yan'}), Node(id='Covid-19', type='Virus', properties={'name': 'Covid-19'}), Node(id='Stock Market', type='Concept', properties={'name': 'Stock Market'}), Node(id='Investing Strategies', type='Concept', properties={'name': 'Investing Strategies'}), Node(id='Camba', type='Person', properties={'name': 'Camba'}), Node(id='Philippines', type='Country', properties={'name': 'Philippines'}), Node(id='Apple', type='Company', properties={'name': 'Apple'}), Node(id='Google', type='Company', properties={'name': 'Google'}), Node(id='Journal Of Asian Finance', type='Journal', properties={'name': 'Journal Of Asian Finance'})] relationships=[Relationship(source=Node(id='Yan', type='Person', properties={'name': 'Yan'}), target=Node(id='Covid-19', type='Virus', properties={'name': 'Covid-19'}), type='research', properties={'title': 'Analysis of the Effect of COVID-19 on the Stock Market and Investing Strategies', 'date': '2020-03-28', 'source': 'https://papers.ssrn.com/sol3/Papers.cfm?abstract_id=3563380'}), Relationship(source=Node(id='Camba', type='Person', properties={'name': 'Camba'}), target=Node(id='Covid-19', type='Virus', properties={'name': 'Covid-19'}), type='research', properties={'title': 'The Effects of Restrictions in Economic Activity on the Spread of COVID-19 in the Philippines: Insights from Apple and Google Mobility Indicators', 'journal': 'Journal of Asian Finance'})] source=Document(page_content='\\n[3] Yan, B. (2020, March 28). Anal ysis of the Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies. Yan. \\nhttps://papers.ssrn.com/sol3/Papers.cfm?abstract_i\\nd=3563380  \\n[4] Camba, J. A. C. (2020). The Effect s of Restrictions \\nin Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance,', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 90%|█████████ | 9/10 [01:52<00:12, 12.73s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'author': 'Shivaani, M. V.', 'publication': 'The Journal of Asian Finance, Economics and Business | Korea Science', 'url': 'https://www.koreascience.or.kr/article/JAKO202034651879125.page', 'name': 'Insights From Apple And Google Mobility Indicators'}), Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'author': 'Shivaani, M. V.', 'publication': 'Journal of Emerging Technologies in Accounting', 'url': 'https://meridian.allenpress.com/jeta/article-abstract/doi/10.2308/JETA-2020-045/464597/Comparing-Apple-to-Amazon-Just-a-Matter-of-Words', 'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), Node(id='Apple (Aapl)', type='Company', properties={'name': 'Apple (Aapl)'}), Node(id='Microsoft (Msft)', type='Company', properties={'name': 'Microsoft (Msft)'})] relationships=[Relationship(source=Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), target=Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'name': 'Insights From Apple And Google Mobility Indicators'}), type='hasInsights'), Relationship(source=Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'name': 'Insights From Apple And Google Mobility Indicators'}), target=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), type='references'), Relationship(source=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), target=Node(id='Apple (Aapl)', type='Company', properties={'name': 'Apple (Aapl)'}), type='comparesTo'), Relationship(source=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), target=Node(id='Microsoft (Msft)', type='Company', properties={'name': 'Microsoft (Msft)'}), type='comparesTo')] source=Document(page_content='in Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance, \\nEconomics and Business | Korea Science. Camba. \\nhttps://www.koreascience.or.kr/article/JAKO2020\\n34651879125.page  \\n[5] Shivaani, M. V. (n.d.). Comparing Apple to \\nAmazon: Just a Matter of Words in Machine \\nLearning World | Journal of Emerging \\nTechnologies in Accounting. Shivaani. Retrieved \\nAugust 29, 2021, from \\nhttps://meridian.allenpress.com/jeta/article -\\nabstract/doi/10.2 308/JETA -2020 -\\n045/464597/Comparing -Apple -to-Amazon -Just-a-\\nMatter -of-Words  \\n[6] Apple (AAPL) Vs Microsoft (MSFT): Which Is A \\nBetter Tech Stock To Buy Right Now?, 28 Jan. \\n2021, www.nasdaq.com/articles/apple -aapl-vs-\\nmicrosoft -msft%3A -which -is-a-better -tech-stock-\\nto-buy-right -now-2021 -01-28. \\n[7] Osipovich Alexander. “Apple’s market capitalisation \\nhas fallen below trillion, and Microsoft is the only \\nremaining U.S. company in the trillion -dollar \\nclub. ” Wall Street News, 24 Mar. 2020, \\ncn.wsj.com/articles /  \\nAdvances in Economics, Business and Management Research, volume 203\\n376', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 10/10 [02:02<00:00, 12.21s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes list : 52\n",
      "Distinct nodes : 41\n",
      "Relationships : 54\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from langchain.text_splitter import TokenTextSplitter\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from datetime import datetime\n",
    "from tqdm import tqdm\n",
    "\n",
    "loader = PyPDFLoader(\"../data/Apple stock during pandemic.pdf\")\n",
    "start_time = datetime.now()\n",
    "pages = loader.load_and_split()\n",
    "# Define chunking strategy\n",
    "text_splitter = TokenTextSplitter(chunk_size=500, chunk_overlap=20)\n",
    "chunks = text_splitter.split_documents(pages)\n",
    "\n",
    "distinct_nodes = set()\n",
    "nodes = []\n",
    "relations = []\n",
    "\n",
    "for i, chunk in tqdm(enumerate(chunks), total=len(chunks)):\n",
    "    graph_document=extract_and_store_graph(chunk)\n",
    "    \n",
    "    #Get distinct nodes\n",
    "    for node in graph_document.nodes :\n",
    "        nodes.append(node.id)\n",
    "        distinct_nodes.add(node.id)\n",
    "         \n",
    "    #Get all relations   \n",
    "    for relation in graph_document.relationships :\n",
    "        relations.append(relation.type)\n",
    "        \n",
    "print(\"nodes list :\", len(nodes))\n",
    "print(\"Distinct nodes :\",len(distinct_nodes))\n",
    "print(\"Relationships :\",len(relations))        "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c45927c0",
   "metadata": {},
   "source": [
    "# With 1000 chunk size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "aa54796c",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'location': 'Cupertino, California', 'founded': 'April 1, 1976', 'industry': 'Technology', 'revenue': 'USD $274.52 billion (2020)', 'marketcap': 'USD $2.43 trillion (2021)'})] relationships=[] source=Document(page_content='The Changes of Apple’s Stock Price During the \\nPandemic  \\nWanting Sun1,* \\n1WendySun, Kinglee High School, Zheng Zhou, He Nan, China, 450000  \\n*Corresponding author. Email:  wendysun040718@163.com  \\nABSTRACT  \\nDuring the epidemic, the economies of various countries, including many large companies, were subject to very large \\nfluctuations and impacts. Therefore, this article will explore the ups and downs of Apple\\'s stock price duri ng the \\nepidemic. At different points in time and severity, Apple\\'s stock price has risen and fallen. By observing the data on \\nYahoo, we can summarize Apple\\'s stock price changes during this period. At the beginning of the epidemic, the global \\neconomy has b een damaged, so Apple is no exception. So at the beginning of the epidemic, Apple\\'s stock price fell \\nsharply. But later, because Apple had a strong overall strength and a good foundation, it only took three months to \\nsolve the impact of the epidemic. Later , when the epidemic returned to a serious situation, Apple\\'s stock price was \\nimplicated and fell slightly, but within a few weeks the stock price decline was resolved and returned to normal levels, \\nand even steadily increased. Because Apple has been consta ntly launching new products, the epidemic will not have a \\nvery large impact on Apple\\'s stock price.  \\nKeywords:  Apple, stock price, COVID -19  \\n1. INTRODUCTION  \\nAs we know, the outbreak of the epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies. Population decline, massive economic \\nlosses, and national unrest. The U.S. economic \\nrecession seems to be more serious than expected. The \\neuro zone economy has experienced the largest decline \\nin record, and the British economy  has also suffered the \\nlargest decline since World War II. As an exogenous \\nshock, the epidemic will inevitably have a direct impact \\non China\\'s transportation, tourism and other industries. \\nSimilarly, as China is the main source of power to \\npromote world gr owth, once the Chinese economy is \\naffected, the world economy will inevitably be affected. \\nThus, in such an environment where the whole world is \\naffected, to what extent have the industry giants that \\ndominate the world been hit? Let\\'s take the most \\nfamilia r Apple company as an example, and analyze \\nhow much impact this devastating epidemic has brought \\nto Apple’s stocks in several aspects . \\n \\n 2. BACKGROUND INFORM ATION OF \\nAPPLE COMPANY  \\nApple Inc. is an American multinational technology \\ncompany that specializes in consumer electronics, \\ncomputer software, and online services. In it’s \\nheadquartered in Cupertino, California. Apple went \\npublic on December 12, 1980, and set a record of \\n$623.5 billion in market value in 2012. As of June \\n2014, Apple has become the world \\'s largest company by \\nmarket capitalization for three consecutive years. On \\nSeptember 30, 2013, in the Hongmeng Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbecome the world\\'s most valuable brand. In 2014, the \\nApple brand surpassed Goog le to become the world\\'s \\nmost valuable brand. On August 19, 2020 local time, \\nApple\\'s market value exceeded US$2 trillion for the \\nfirst time. Ranked 6th on the Fortune Global 500 list in \\n2021. Apple is the world\\'s largest technology company \\nby revenue and, since January 2021, the world\\'s most \\nvaluable company. As of 2021, Apple is the world\\'s \\nfourth -largest PC vendor by unit sales, and fourth -\\nlargest smartphone manufacturer.  \\n \\nAdvances in Economics, Business and Management Research, volume 203\\nProceedings of the 2021 3rd International Conference on Economic Management and\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis Press International\\xa0B.V.\\nThis is an open access article distributed under the CC BY-NC 4.0 license -http://creativecommons.org/licenses/by-nc/4.0/. 373', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 17%|█▋        | 1/6 [00:04<00:24,  4.93s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Macro_Perspective', type='Perspective', properties={'description': 'From a macro perspective, the decline in population, the decrease in spending, and the increase in inventories have caused many industries to stagnate. This is bound to bring a huge blow on the global economy to a serious extent.', 'name': 'Macro_Perspective'}), Node(id='Global_Economy', type='Concept', properties={'description': 'The global economy is expected to shrink by 3% in 2020 due to the new crown epidemic, with a more severe impact than the 2008-2009 financial crisis.', 'name': 'Global_Economy'}), Node(id='Economic_Survey', type='Publication', properties={'title': 'April 2020 Global Economic Survey', 'name': 'Economic_Survey'}), Node(id='Epidemic_Impact', type='Concept', properties={'description': 'The impact of the epidemic crisis on economic contraction is predicted to be three times that of the financial crisis.', 'name': 'Epidemic_Impact'}), Node(id='Global_Recession', type='Event', properties={'start_date': '2007-12-31', 'end_date': '2009-06-30', 'name': 'Global_Recession'}), Node(id='Apple', type='Company', properties={'components_production_location': 'China', 'stock_price': 'US$981.7 billion', 'name': 'Apple'}), Node(id='Wall_Street_Journal', type='Publication', properties={'date': '2020-03-24', 'name': 'Wall_Street_Journal'}), Node(id='Trillion_Club', type='Concept', properties={'description': \"Apple fell out of the 'trillion club' of US stocks, with only Microsoft remaining.\", 'name': 'Trillion_Club'}), Node(id='Micro_Perspective', type='Perspective', properties={'description': \"Apple's stock price started to decline in February, reached its lowest point on March 23, and gradually increased until September 1. After that, the price started to drop again.\", 'name': 'Micro_Perspective'}), Node(id='Stock_Price_Figure', type='Figure', properties={'description': \"Figure 1: Apple's stock price\", 'name': 'Stock_Price_Figure'})] relationships=[Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Global_Economy', type='Concept', properties={'name': 'Global_Economy'}), type='has_impact_on'), Relationship(source=Node(id='Macro_Perspective', type='Perspective', properties={'name': 'Macro_Perspective'}), target=Node(id='Economic_Survey', type='Publication', properties={'name': 'Economic_Survey'}), type='mentions'), Relationship(source=Node(id='Global_Economy', type='Concept', properties={'name': 'Global_Economy'}), target=Node(id='Epidemic_Impact', type='Concept', properties={'name': 'Epidemic_Impact'}), type='has_impact_on'), Relationship(source=Node(id='Global_Economy', type='Concept', properties={'name': 'Global_Economy'}), target=Node(id='Global_Recession', type='Event', properties={'name': 'Global_Recession'}), type='has_more_severe_impact_than'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Components_Production_Location', type='Concept', properties={'name': 'Components_Production_Location'}), type='produces'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Wall_Street_Journal', type='Publication', properties={'name': 'Wall_Street_Journal'}), type='reports'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Trillion_Club', type='Concept', properties={'name': 'Trillion_Club'}), type='fell_out_of'), Relationship(source=Node(id='Micro_Perspective', type='Perspective', properties={'name': 'Micro_Perspective'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='has_impact_on'), Relationship(source=Node(id='Micro_Perspective', type='Perspective', properties={'name': 'Micro_Perspective'}), target=Node(id='Stock_Price_Figure', type='Figure', properties={'name': 'Stock_Price_Figure'}), type='mentions')] source=Document(page_content='3. MACRO PERSPECTIVE   \\nFrom a macro perspective, the decline in population, \\nthe decrease in spending, and the increase in inventories \\nhave caused many industries to stagnate. This is bound \\nto bring a huge blow on the global economy to a serious \\nextent. The International Monetary  Fund stated in the \\n\"April 2020 Global Economic Survey\" that due to the \\nnew crown epidemic, the global economy is expected to \\nshrink by 3% in 2020, and the impact will be much \\nmore severe than the 2008 -2009 financial crisis. Some \\nexperts have predicted tha t the impact of the epidemic \\ncrisis on economic contraction will be three times that \\nof the financial crisis. The last global economic \\nrecession began at the end of 2007 and did not fully \\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so when China is affected by the \\nepidemic and the work is stopped, Apple\\'s products \\ncannot be made at the same time [3]. This will \\ninevitably have a huge impact on Apple. According to \\ninformation reported by the Wall Street Journal on \\nMarch 24, 2020 , Apple\\'s stock price closed down 2.12% \\non Monday, and its market value fell below US$1 trillion to US$981.7 billion. In this way, Apple fell out \\nof the \"trillion club\" of US stocks, of which only \\nMicrosoft was left [7].  \\n4. MICRO PERSPECTIVE  \\nIt is obvious that Apple has been affected by the \\nepidemic in a great extent, however, we still need to \\ntake a look Apple’s economic changes in a micro \\nperspective. At the beginning of the epidemic, which is \\nthe start of February, the price started to decline. On \\nFebrua ry 3, 2020, the opening price is 76.07; the \\nclosing price is 80.01. From this point, the closing price \\nstarted to diminish. On March 23, 2020, the opening \\nprice is 57.02, and the closing price is 56.09. The stock \\nprice for this day is the lowest price duri ng epidemic in \\nApple. Then, it started to increase gradually until \\nSeptember 1, this day is also a peak, the opening price \\non September 1 is 132.76 and the closing price is \\n134.18. However, after September 1, the price started to \\ndrop again. There is a ver y low price on September 18, \\n2020. The opening price is 110.40, the closing price is \\n106.84.  \\n \\nFigure 1 Apple\\'s stock price  \\n \\n \\nAdvances in Economics, Business and Management Research, volume 203\\n374', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 33%|███▎      | 2/6 [00:27<01:01, 15.28s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Microsoft'})] relationships=[] source=Document(page_content=\"Figure 2.  Apple's stock price  \\nThe reasons which caused this drop might be a lot, \\nthe most common answer might be the delay of the \\nannouncement of new Apple Products. A numbers of \\npeople waiting on this day for a long time, because \\nApple supposed to announce the new products like \\niPhone  12, iPhone 12 Pro and iPhone 12 Pro Max, etc. \\nNevertheless, Apple delayed the publish of their new \\nproducts until October 14, 2020. There is a small peak \\nof rising stock price on October 12, which is two days \\nbefore the publish of the new products. The in creasing \\nof Apple stock might because people putted huge \\nexpectations on these new products, and they have been \\nwaited for a long period. This motivation lead them to \\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’ stock . On \\nNovember 2, there is a small drop on this day. The \\nopening price is 109.11, and the closing price is 108.77. \\nOn December 28, there is another increasing peak on \\nApple’s stock. The opening price is 133.99, and the \\nclosing price 136.69. This is also the  highest price of \\nApple stock in 2020. After 2020, Apple's stock price \\nwill continue to increase in 2021. This study used two \\nyears of data for comparison, which means it will only \\nuse data from February 3, 2021 and before. So at the \\nbeginning of 2021, App le’s stock price ushered in its \\nfirst peak. On January 26, 2021, the opening price is \\n143.6, and the closing price is 143.16. Later on, there is \\na small drop until February 3, 2021. The opening price \\nis 135.76, and the closing price is 133.94. Comparing \\nthe data at the same day but different year on February \\n3, we can see that the price of Apple’s stock increased \\nby 67.4% in one year.  5. COMPARISON WITH M ICROSOFT \\nCOMPANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Microsof t is an \\nAmerican multinational technology company founded \\nby Bill Gates and Paul Allen on April 4, 1975. The \\ncompany is headquartered in Redmond, Washington \\n(near Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of computer \\nsoftware services. The most famous and best -selling \\nproducts are Windows operating system and Office \\nseries software. It is the world's largest computer \\nsoftware provider and the leader of PC (Personal \\nComputer) software development in the world. On June \\n23, 2021, Microsoft's market value exceeded the $2 \\ntrillion mark. This is the second US company to enter \\nafter Apple's breakthrough of $2 trillion. In 2019, the \\nmarket value of Microsoft reached US$1 trillion for the \\nfirst time, 33 years after the original Mi crosoft IPO. \\nFrom 1 trillion to 2 trillion, Microsoft only took about 2 \\nyears. Comparing Microsoft and Apple, Microsoft has \\nmore patents, company environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit, profit \\nmargin, revenue, etc. are more t han that of Microsoft. \\nThis is why Apple’s market value can break 2 trillion \\nearlier than Microsoft. On the two items of profit and \\nprofit margin, Microsoft's performance is not good. \\nAfter all, it is an enterprise -level market. If the profit \\nmargin is too  high, customers are easy to lose.  \\nDuring the epidemic, Microsoft let their employees \\nto work at home, Its stock price has also changed more \\nor less with the epidemic flow. In March 6, 2020 report, \\nAdvances in Economics, Business and Management Research, volume 203\\n375\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 50%|█████     | 3/6 [00:32<00:31, 10.41s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'stockpriceplummeted': '14.74%', 'largestsingledaydrop': 'April 24, 2000', 'stockpricefallen': '27%', 'name': 'Microsoft'}), Node(id='Monday', type='Day', properties={'name': 'Monday'}), Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), Node(id='March 23', type='Date', properties={'name': 'March 23'}), Node(id='March 16', type='Date', properties={'openingprice': '140.0', 'closingprice': '135.42', 'name': 'March 16'}), Node(id='Apple', type='Company', properties={'lowestpricedate': 'March 23', 'highestpricedate': 'December', 'overalltrendincrease': '67.4%', 'name': 'Apple'}), Node(id='August', type='Month', properties={'name': 'August'}), Node(id='November', type='Month', properties={'name': 'November'}), Node(id='2021', type='Year', properties={'name': '2021'}), Node(id='September', type='Month', properties={'name': 'September'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Monday', type='Day', properties={'name': 'Monday'}), type='stockPricePlummetedOn', properties={'percentage': '14.74%'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), type='largestSingleDayDropOn', properties={'percentage': '15.6%'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn', properties={'openingprice': '140.0', 'closingprice': '135.42'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='comparison', properties={'stockpricecomparison': 'higher', 'transactionvolumecomparison': 'lower'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowestPriceOn', properties={'price': 'March 23'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='December', type='Month', properties={'name': 'December'}), type='highestPriceIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='August', type='Month', properties={'name': 'August'}), type='riseFirstAndFallBackIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='November', type='Month', properties={'name': 'November'}), type='fallBackToNormalIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='2021', type='Year', properties={'name': '2021'}), type='peakIn', properties={'percentage': '67.4%'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), type='stockDecreaseSince', properties={'date': 'February 10, 2020'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='badSituationOn', properties={'price': 'March 23'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn', properties={'openingprice': '140.0', 'closingprice': '135.42'}), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='comparison', properties={'stockpricecomparison': 'higher', 'transactionvolumecomparison': 'lower'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowestPriceOn', properties={'price': 'March 23'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='December', type='Month', properties={'name': 'December'}), type='highestPriceIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='August', type='Month', properties={'name': 'August'}), type='riseFirstAndFallBackIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='November', type='Month', properties={'name': 'November'}), type='fallBackToNormalIn', properties={'year': '2020'}), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='2021', type='Year', properties={'name': '2021'}), type='peakIn', properties={'percentage': '67.4%'})] source=Document(page_content=\"Microsoft's stock price plummeted 14.74% on Monday, \\nthe la rgest single -day drop since April 24, 2000. At that \\ntime, Microsoft's stock price fell by 15.6%. In the past \\nmonth, Microsoft's stock price has fallen by 27%, and \\nthe Dow has fallen by 31% [5].  \\nIn a micro perspective, during epidemic time, \\nMicrosoft’s stoc k start decrease since February 10, \\n2020. At the time when Apple had their its lowest price \\non March 23, Microsoft also having a bad situation, but \\nthe lowest price of Microsoft price is on March 16. The \\nopening price on that day is 140.0, the closing pric e is \\n135.42. Even thought the stock price of Microsoft is \\nmuch higher than Apple, but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\nMicrosoft. It is because Apple's market value is higher \\nthan Microsoft.  \\n6. OVERALL TREND  \\nFor Apple, th e epidemic only affected it at the \\nbeginning, but it took only four months for Apple to \\nreturn to its previous normal stock price. It can be seen \\nthat the true hidden strength behind Apple can enable \\nApple. Recovered in such a short time. The overall \\nsitua tion of Apple's stock price continued to rise. It only \\nfell sharply between February and June, when the \\nepidemic first began, but it quickly returned to its \\noriginal state. During the period from August to \\nNovember, the impact of Apple's new products rose \\nfirst and then fell back to normal levels. There was also \\na peak in early 2021, and then it returned to normal \\nlevels. The overall level of Apple's stock increased by \\n67.4% over the same period.  \\nFor Microsoft, his situation is actually similar to that \\nof the same type of Apple. At the beginning of the \\nepidemic, there was a huge decline from February to \\nMarch, but it was basically fully restored to the \\nprevious level before June. Like Apple, it took just four \\nmonths to solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot \\nbe underestimated. Microsoft's overall trend continues \\nto rise. However, unlike Apple, the highest value of \\nApple's stock is in December, which is the end of 2020, \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September, the stock declined \\nslightly, but it only fell to a normal level, and then \\nslowly climbed up.  \\n7. CONCLUSION  \\nComparing Apple's stock price and Microsoft's \\nstock price, we can find that Microsoft's stock price is \\nmuch h igher than Apple's, but when we compare their \\nnumber of transactions, we find that Apple's number of \\ntransactions is many times greater than that of \\nMicrosoft. This has also led to the fact that the total \\ntrading volume of Apple stock and Microsoft stock i s similar, and sometimes Apple is even higher than \\nMicrosoft.  \\nTo conclude, the pandemic did not bring an \\nirreparable blow to Apple. Instead, it only took it four \\nmonths to restore its stock to its original value, or even \\nrise. This is enough to show that Apple's foundation is \\nstable and there are excellent strategies to enable them \\nto recover their losses in time when they faced strong \\nimpacts. In general, Apple's stock only declined during \\nthe most severe period of the pandemic, and remained \\nat a stable value for the rest of the time, and there was \\nalso a phenomenon of continuous ri se. \\nREFERENCES  \\n[1] Yahoo is now a part of Verizon Media. (n.d.). \\nYahoo. Retrieved August 29, 2021, from \\nhttps://finance.yahoo.com/quote/AAPL/chart? \\\\ \\n[2] Ziemba, W. T. (2020, June 21). The COVID -19 \\nCrash in the US Stock Market. Ziemba. \\nhttps://papers.ssrn.com/sol3/papers.cfm?abstract_i\\nd=3632410  \\n[3] Yan, B. (2020, March 28). Anal ysis of the Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 67%|██████▋   | 4/6 [01:09<00:42, 21.10s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'}), Node(id='Stock Market', type='Concept', properties={'name': 'Stock Market'}), Node(id='Investing Strategies', type='Concept', properties={'name': 'Investing Strategies'}), Node(id='Yan', type='Person', properties={'name': 'Yan'}), Node(id='Https://Papers.Ssrn.Com/Sol3/Papers.Cfm?Abstract_Id=3563380', type='Source', properties={'name': 'Https://Papers.Ssrn.Com/Sol3/Papers.Cfm?Abstract_Id=3563380'}), Node(id='Camba, J. A. C.', type='Person', properties={'name': 'Camba, J. A. C.'}), Node(id='The Journal Of Asian Finance', type='Journal', properties={'name': 'The Journal Of Asian Finance'})] relationships=[Relationship(source=Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'}), target=Node(id='Stock Market', type='Concept', properties={'name': 'Stock Market'}), type='effect'), Relationship(source=Node(id='Covid-19', type='Concept', properties={'name': 'Covid-19'}), target=Node(id='Investing Strategies', type='Concept', properties={'name': 'Investing Strategies'}), type='effect'), Relationship(source=Node(id='Yan', type='Person', properties={'name': 'Yan'}), target=Node(id='Https://Papers.Ssrn.Com/Sol3/Papers.Cfm?Abstract_Id=3563380', type='Source', properties={'name': 'Https://Papers.Ssrn.Com/Sol3/Papers.Cfm?Abstract_Id=3563380'}), type='author'), Relationship(source=Node(id='Camba, J. A. C.', type='Person', properties={'name': 'Camba, J. A. C.'}), target=Node(id='The Journal Of Asian Finance', type='Journal', properties={'name': 'The Journal Of Asian Finance'}), type='publication')] source=Document(page_content=' Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies. Yan. \\nhttps://papers.ssrn.com/sol3/Papers.cfm?abstract_i\\nd=3563380  \\n[4] Camba, J. A. C. (2020). The Effect s of Restrictions \\nin Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance,', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 83%|████████▎ | 5/6 [01:20<00:17, 17.56s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), Node(id='Insights From Apple And Google Mobility Indicators', type='Journal', properties={'source': 'The Journal of Asian Finance, Economics and Business | Korea Science', 'link': 'https://www.koreascience.or.kr/article/JAKO202034651879125.page', 'name': 'Insights From Apple And Google Mobility Indicators'}), Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'author': 'Shivaani, M. V.', 'journal': 'Journal of Emerging Technologies in Accounting', 'source': 'Machine Learning World', 'link': 'https://meridian.allenpress.com/jeta/article-abstract/doi/10.2308/JETA-2020-045/464597/Comparing-Apple-to-Amazon-Just-a-Matter-of-Words', 'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), Node(id='Apple (Aapl)', type='Company', properties={'name': 'Apple (Aapl)'}), Node(id='Microsoft (Msft)', type='Company', properties={'name': 'Microsoft (Msft)'}), Node(id=\"Apple'S Market Capitalisation\", type='Concept', properties={'description': \"Apple's market capitalisation has fallen below trillion, and Microsoft is the only remaining U.S. company in the trillion-dollar club.\", 'source': 'Wall Street News', 'date': '24 Mar. 2020', 'link': 'cn.wsj.com/articles', 'name': \"Apple'S Market Capitalisation\"})] relationships=[Relationship(source=Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), target=Node(id='Insights From Apple And Google Mobility Indicators', type='Journal', properties={'name': 'Insights From Apple And Google Mobility Indicators'}), type='published_in'), Relationship(source=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), target=Node(id='Journal Of Emerging Technologies In Accounting', type='Journal', properties={'name': 'Journal Of Emerging Technologies In Accounting'}), type='published_in'), Relationship(source=Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), target=Node(id='Machine Learning World', type='Journal', properties={'name': 'Machine Learning World'}), type='published_in'), Relationship(source=Node(id='Apple (Aapl)', type='Company', properties={'name': 'Apple (Aapl)'}), target=Node(id='Microsoft (Msft)', type='Company', properties={'name': 'Microsoft (Msft)'}), type='comparison'), Relationship(source=Node(id=\"Apple'S Market Capitalisation\", type='Concept', properties={'name': \"Apple'S Market Capitalisation\"}), target=Node(id='Apple (Aapl)', type='Company', properties={'name': 'Apple (Aapl)'}), type='has_market_capitalisation'), Relationship(source=Node(id=\"Apple'S Market Capitalisation\", type='Concept', properties={'name': \"Apple'S Market Capitalisation\"}), target=Node(id='Microsoft (Msft)', type='Company', properties={'name': 'Microsoft (Msft)'}), type='has_market_capitalisation')] source=Document(page_content='in Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance, \\nEconomics and Business | Korea Science. Camba. \\nhttps://www.koreascience.or.kr/article/JAKO2020\\n34651879125.page  \\n[5] Shivaani, M. V. (n.d.). Comparing Apple to \\nAmazon: Just a Matter of Words in Machine \\nLearning World | Journal of Emerging \\nTechnologies in Accounting. Shivaani. Retrieved \\nAugust 29, 2021, from \\nhttps://meridian.allenpress.com/jeta/article -\\nabstract/doi/10.2 308/JETA -2020 -\\n045/464597/Comparing -Apple -to-Amazon -Just-a-\\nMatter -of-Words  \\n[6] Apple (AAPL) Vs Microsoft (MSFT): Which Is A \\nBetter Tech Stock To Buy Right Now?, 28 Jan. \\n2021, www.nasdaq.com/articles/apple -aapl-vs-\\nmicrosoft -msft%3A -which -is-a-better -tech-stock-\\nto-buy-right -now-2021 -01-28. \\n[7] Osipovich Alexander. “Apple’s market capitalisation \\nhas fallen below trillion, and Microsoft is the only \\nremaining U.S. company in the trillion -dollar \\nclub. ” Wall Street News, 24 Mar. 2020, \\ncn.wsj.com/articles /  \\nAdvances in Economics, Business and Management Research, volume 203\\n376', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 6/6 [01:40<00:00, 16.68s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes list : 37\n",
      "Distinct nodes : 33\n",
      "Relationships : 37\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from langchain.text_splitter import TokenTextSplitter\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from datetime import datetime\n",
    "\n",
    "loader = PyPDFLoader(\"../data/Apple stock during pandemic.pdf\")\n",
    "start_time = datetime.now()\n",
    "pages = loader.load_and_split()\n",
    "# Define chunking strategy\n",
    "text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=20)\n",
    "chunks = text_splitter.split_documents(pages)\n",
    "\n",
    "distinct_nodes = set()\n",
    "nodes = []\n",
    "relations = []\n",
    "\n",
    "for i, chunk in tqdm(enumerate(chunks), total=len(chunks)):\n",
    "    graph_document=extract_and_store_graph(chunk)\n",
    "    \n",
    "    #Get distinct nodes\n",
    "    for node in graph_document.nodes :\n",
    "        nodes.append(node.id)\n",
    "        distinct_nodes.add(node.id)\n",
    "         \n",
    "    #Get all relations   \n",
    "    for relation in graph_document.relationships :\n",
    "        relations.append(relation.type)\n",
    "\n",
    "print(\"nodes list :\", len(nodes))\n",
    "print(\"Distinct nodes :\",len(distinct_nodes))\n",
    "print(\"Relationships :\",len(relations))        "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51d75523",
   "metadata": {},
   "source": [
    "# With 2000 chunk size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "a2379665",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/5 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'location': 'Cupertino, California', 'founded': 'April 1, 1976', 'industry': 'Technology', 'revenue': 'USD $274.52 billion (2020)', 'marketcapitalization': 'USD $2.43 trillion (2021)'})] relationships=[] source=Document(page_content='The Changes of Apple’s Stock Price During the \\nPandemic  \\nWanting Sun1,* \\n1WendySun, Kinglee High School, Zheng Zhou, He Nan, China, 450000  \\n*Corresponding author. Email:  wendysun040718@163.com  \\nABSTRACT  \\nDuring the epidemic, the economies of various countries, including many large companies, were subject to very large \\nfluctuations and impacts. Therefore, this article will explore the ups and downs of Apple\\'s stock price duri ng the \\nepidemic. At different points in time and severity, Apple\\'s stock price has risen and fallen. By observing the data on \\nYahoo, we can summarize Apple\\'s stock price changes during this period. At the beginning of the epidemic, the global \\neconomy has b een damaged, so Apple is no exception. So at the beginning of the epidemic, Apple\\'s stock price fell \\nsharply. But later, because Apple had a strong overall strength and a good foundation, it only took three months to \\nsolve the impact of the epidemic. Later , when the epidemic returned to a serious situation, Apple\\'s stock price was \\nimplicated and fell slightly, but within a few weeks the stock price decline was resolved and returned to normal levels, \\nand even steadily increased. Because Apple has been consta ntly launching new products, the epidemic will not have a \\nvery large impact on Apple\\'s stock price.  \\nKeywords:  Apple, stock price, COVID -19  \\n1. INTRODUCTION  \\nAs we know, the outbreak of the epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies. Population decline, massive economic \\nlosses, and national unrest. The U.S. economic \\nrecession seems to be more serious than expected. The \\neuro zone economy has experienced the largest decline \\nin record, and the British economy  has also suffered the \\nlargest decline since World War II. As an exogenous \\nshock, the epidemic will inevitably have a direct impact \\non China\\'s transportation, tourism and other industries. \\nSimilarly, as China is the main source of power to \\npromote world gr owth, once the Chinese economy is \\naffected, the world economy will inevitably be affected. \\nThus, in such an environment where the whole world is \\naffected, to what extent have the industry giants that \\ndominate the world been hit? Let\\'s take the most \\nfamilia r Apple company as an example, and analyze \\nhow much impact this devastating epidemic has brought \\nto Apple’s stocks in several aspects . \\n \\n 2. BACKGROUND INFORM ATION OF \\nAPPLE COMPANY  \\nApple Inc. is an American multinational technology \\ncompany that specializes in consumer electronics, \\ncomputer software, and online services. In it’s \\nheadquartered in Cupertino, California. Apple went \\npublic on December 12, 1980, and set a record of \\n$623.5 billion in market value in 2012. As of June \\n2014, Apple has become the world \\'s largest company by \\nmarket capitalization for three consecutive years. On \\nSeptember 30, 2013, in the Hongmeng Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbecome the world\\'s most valuable brand. In 2014, the \\nApple brand surpassed Goog le to become the world\\'s \\nmost valuable brand. On August 19, 2020 local time, \\nApple\\'s market value exceeded US$2 trillion for the \\nfirst time. Ranked 6th on the Fortune Global 500 list in \\n2021. Apple is the world\\'s largest technology company \\nby revenue and, since January 2021, the world\\'s most \\nvaluable company. As of 2021, Apple is the world\\'s \\nfourth -largest PC vendor by unit sales, and fourth -\\nlargest smartphone manufacturer.  \\n \\nAdvances in Economics, Business and Management Research, volume 203\\nProceedings of the 2021 3rd International Conference on Economic Management and\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis Press International\\xa0B.V.\\nThis is an open access article distributed under the CC BY-NC 4.0 license -http://creativecommons.org/licenses/by-nc/4.0/. 373', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 20%|██        | 1/5 [00:04<00:19,  4.97s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Macroperspective', type='Perspective', properties={'description': 'From a macro perspective, the decline in population, the decrease in spending, and the increase in inventories have caused many industries to stagnate. This is bound to bring a huge blow on the global economy to a serious extent.', 'name': 'Macroperspective'}), Node(id='Globaleconomy', type='Concept', properties={'description': 'The global economy is expected to shrink by 3% in 2020 due to the new crown epidemic. The impact will be much more severe than the 2008-2009 financial crisis.', 'name': 'Globaleconomy'}), Node(id='Economicsurvey', type='Publication', properties={'title': 'April 2020 Global Economic Survey', 'name': 'Economicsurvey'}), Node(id='Experts', type='Group', properties={'description': 'Some experts have predicted that the impact of the epidemic crisis on economic contraction will be three times that of the financial crisis.', 'name': 'Experts'}), Node(id='Recession', type='Event', properties={'description': 'The last global economic recession began at the end of 2007 and did not fully recover until June 2009.', 'name': 'Recession'}), Node(id='Apple', type='Company', properties={'description': \"Apple's stock price closed down 2.12% on March 24, 2020, and its market value fell below US$1 trillion to US$981.7 billion.\", 'name': 'Apple'}), Node(id='Wallstreetjournal', type='Publication', properties={'title': 'Wall Street Journal', 'name': 'Wallstreetjournal'}), Node(id='Microperspective', type='Perspective', properties={'description': \"Apple's stock price started to decline at the beginning of the epidemic. It reached its lowest point on March 23, 2020, and gradually increased until September 1. After that, the price started to drop again.\", 'name': 'Microperspective'})] relationships=[Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Globaleconomy', type='Concept', properties={'name': 'Globaleconomy'}), type='hasImpactOn'), Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Economicsurvey', type='Publication', properties={'name': 'Economicsurvey'}), type='mentions'), Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Experts', type='Group', properties={'name': 'Experts'}), type='mentions'), Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Recession', type='Event', properties={'name': 'Recession'}), type='mentions'), Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='hasImpactOn'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Wallstreetjournal', type='Publication', properties={'name': 'Wallstreetjournal'}), type='mentionedIn'), Relationship(source=Node(id='Microperspective', type='Perspective', properties={'name': 'Microperspective'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='hasImpactOn')] source=Document(page_content='3. MACRO PERSPECTIVE   \\nFrom a macro perspective, the decline in population, \\nthe decrease in spending, and the increase in inventories \\nhave caused many industries to stagnate. This is bound \\nto bring a huge blow on the global economy to a serious \\nextent. The International Monetary  Fund stated in the \\n\"April 2020 Global Economic Survey\" that due to the \\nnew crown epidemic, the global economy is expected to \\nshrink by 3% in 2020, and the impact will be much \\nmore severe than the 2008 -2009 financial crisis. Some \\nexperts have predicted tha t the impact of the epidemic \\ncrisis on economic contraction will be three times that \\nof the financial crisis. The last global economic \\nrecession began at the end of 2007 and did not fully \\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so when China is affected by the \\nepidemic and the work is stopped, Apple\\'s products \\ncannot be made at the same time [3]. This will \\ninevitably have a huge impact on Apple. According to \\ninformation reported by the Wall Street Journal on \\nMarch 24, 2020 , Apple\\'s stock price closed down 2.12% \\non Monday, and its market value fell below US$1 trillion to US$981.7 billion. In this way, Apple fell out \\nof the \"trillion club\" of US stocks, of which only \\nMicrosoft was left [7].  \\n4. MICRO PERSPECTIVE  \\nIt is obvious that Apple has been affected by the \\nepidemic in a great extent, however, we still need to \\ntake a look Apple’s economic changes in a micro \\nperspective. At the beginning of the epidemic, which is \\nthe start of February, the price started to decline. On \\nFebrua ry 3, 2020, the opening price is 76.07; the \\nclosing price is 80.01. From this point, the closing price \\nstarted to diminish. On March 23, 2020, the opening \\nprice is 57.02, and the closing price is 56.09. The stock \\nprice for this day is the lowest price duri ng epidemic in \\nApple. Then, it started to increase gradually until \\nSeptember 1, this day is also a peak, the opening price \\non September 1 is 132.76 and the closing price is \\n134.18. However, after September 1, the price started to \\ndrop again. There is a ver y low price on September 18, \\n2020. The opening price is 110.40, the closing price is \\n106.84.  \\n \\nFigure 1 Apple\\'s stock price  \\n \\n \\nAdvances in Economics, Business and Management Research, volume 203\\n374', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 40%|████      | 2/5 [00:21<00:34, 11.62s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Microsoft'})] relationships=[] source=Document(page_content=\"Figure 2.  Apple's stock price  \\nThe reasons which caused this drop might be a lot, \\nthe most common answer might be the delay of the \\nannouncement of new Apple Products. A numbers of \\npeople waiting on this day for a long time, because \\nApple supposed to announce the new products like \\niPhone  12, iPhone 12 Pro and iPhone 12 Pro Max, etc. \\nNevertheless, Apple delayed the publish of their new \\nproducts until October 14, 2020. There is a small peak \\nof rising stock price on October 12, which is two days \\nbefore the publish of the new products. The in creasing \\nof Apple stock might because people putted huge \\nexpectations on these new products, and they have been \\nwaited for a long period. This motivation lead them to \\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’ stock . On \\nNovember 2, there is a small drop on this day. The \\nopening price is 109.11, and the closing price is 108.77. \\nOn December 28, there is another increasing peak on \\nApple’s stock. The opening price is 133.99, and the \\nclosing price 136.69. This is also the  highest price of \\nApple stock in 2020. After 2020, Apple's stock price \\nwill continue to increase in 2021. This study used two \\nyears of data for comparison, which means it will only \\nuse data from February 3, 2021 and before. So at the \\nbeginning of 2021, App le’s stock price ushered in its \\nfirst peak. On January 26, 2021, the opening price is \\n143.6, and the closing price is 143.16. Later on, there is \\na small drop until February 3, 2021. The opening price \\nis 135.76, and the closing price is 133.94. Comparing \\nthe data at the same day but different year on February \\n3, we can see that the price of Apple’s stock increased \\nby 67.4% in one year.  5. COMPARISON WITH M ICROSOFT \\nCOMPANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Microsof t is an \\nAmerican multinational technology company founded \\nby Bill Gates and Paul Allen on April 4, 1975. The \\ncompany is headquartered in Redmond, Washington \\n(near Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of computer \\nsoftware services. The most famous and best -selling \\nproducts are Windows operating system and Office \\nseries software. It is the world's largest computer \\nsoftware provider and the leader of PC (Personal \\nComputer) software development in the world. On June \\n23, 2021, Microsoft's market value exceeded the $2 \\ntrillion mark. This is the second US company to enter \\nafter Apple's breakthrough of $2 trillion. In 2019, the \\nmarket value of Microsoft reached US$1 trillion for the \\nfirst time, 33 years after the original Mi crosoft IPO. \\nFrom 1 trillion to 2 trillion, Microsoft only took about 2 \\nyears. Comparing Microsoft and Apple, Microsoft has \\nmore patents, company environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit, profit \\nmargin, revenue, etc. are more t han that of Microsoft. \\nThis is why Apple’s market value can break 2 trillion \\nearlier than Microsoft. On the two items of profit and \\nprofit margin, Microsoft's performance is not good. \\nAfter all, it is an enterprise -level market. If the profit \\nmargin is too  high, customers are easy to lose.  \\nDuring the epidemic, Microsoft let their employees \\nto work at home, Its stock price has also changed more \\nor less with the epidemic flow. In March 6, 2020 report, \\nAdvances in Economics, Business and Management Research, volume 203\\n375\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 60%|██████    | 3/5 [00:25<00:16,  8.14s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'stockpriceplummeted': '14.74%', 'largestsingledaydrop': 'April 24, 2000', 'stockpricefallen': '27%', 'name': 'Microsoft'}), Node(id='Monday', type='Day', properties={'name': 'Monday'}), Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), Node(id='March 23', type='Date', properties={'name': 'March 23'}), Node(id='March 16', type='Date', properties={'name': 'March 16'}), Node(id='140.0', type='Number', properties={'name': '140.0'}), Node(id='135.42', type='Number', properties={'name': '135.42'}), Node(id='Apple', type='Company', properties={'lowestpricedate': 'March 23', 'openingprice': '140.0', 'closingprice': '135.42', 'marketvalue': 'higher than Microsoft', 'name': 'Apple'}), Node(id='August', type='Month', properties={'name': 'August'}), Node(id='November', type='Month', properties={'name': 'November'}), Node(id='Early 2021', type='Year', properties={'name': 'Early 2021'}), Node(id='67.4%', type='Percentage', properties={'name': '67.4%'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Monday', type='Day', properties={'name': 'Monday'}), type='stockPricePlummetedOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), type='largestSingleDayDropOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), type='stockDecreaseStartOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowestPriceOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='marketValueComparison'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='August', type='Month', properties={'name': 'August'}), type='impactOfNewProducts'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='November', type='Month', properties={'name': 'November'}), type='impactOfNewProducts'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Early 2021', type='Year', properties={'name': 'Early 2021'}), type='impactOfNewProducts'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='stockPriceComparison')] source=Document(page_content=\"Microsoft's stock price plummeted 14.74% on Monday, \\nthe la rgest single -day drop since April 24, 2000. At that \\ntime, Microsoft's stock price fell by 15.6%. In the past \\nmonth, Microsoft's stock price has fallen by 27%, and \\nthe Dow has fallen by 31% [5].  \\nIn a micro perspective, during epidemic time, \\nMicrosoft’s stoc k start decrease since February 10, \\n2020. At the time when Apple had their its lowest price \\non March 23, Microsoft also having a bad situation, but \\nthe lowest price of Microsoft price is on March 16. The \\nopening price on that day is 140.0, the closing pric e is \\n135.42. Even thought the stock price of Microsoft is \\nmuch higher than Apple, but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\nMicrosoft. It is because Apple's market value is higher \\nthan Microsoft.  \\n6. OVERALL TREND  \\nFor Apple, th e epidemic only affected it at the \\nbeginning, but it took only four months for Apple to \\nreturn to its previous normal stock price. It can be seen \\nthat the true hidden strength behind Apple can enable \\nApple. Recovered in such a short time. The overall \\nsitua tion of Apple's stock price continued to rise. It only \\nfell sharply between February and June, when the \\nepidemic first began, but it quickly returned to its \\noriginal state. During the period from August to \\nNovember, the impact of Apple's new products rose \\nfirst and then fell back to normal levels. There was also \\na peak in early 2021, and then it returned to normal \\nlevels. The overall level of Apple's stock increased by \\n67.4% over the same period.  \\nFor Microsoft, his situation is actually similar to that \\nof the same type of Apple. At the beginning of the \\nepidemic, there was a huge decline from February to \\nMarch, but it was basically fully restored to the \\nprevious level before June. Like Apple, it took just four \\nmonths to solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot \\nbe underestimated. Microsoft's overall trend continues \\nto rise. However, unlike Apple, the highest value of \\nApple's stock is in December, which is the end of 2020, \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September, the stock declined \\nslightly, but it only fell to a normal level, and then \\nslowly climbed up.  \\n7. CONCLUSION  \\nComparing Apple's stock price and Microsoft's \\nstock price, we can find that Microsoft's stock price is \\nmuch h igher than Apple's, but when we compare their \\nnumber of transactions, we find that Apple's number of \\ntransactions is many times greater than that of \\nMicrosoft. This has also led to the fact that the total \\ntrading volume of Apple stock and Microsoft stock i s similar, and sometimes Apple is even higher than \\nMicrosoft.  \\nTo conclude, the pandemic did not bring an \\nirreparable blow to Apple. Instead, it only took it four \\nmonths to restore its stock to its original value, or even \\nrise. This is enough to show that Apple's foundation is \\nstable and there are excellent strategies to enable them \\nto recover their losses in time when they faced strong \\nimpacts. In general, Apple's stock only declined during \\nthe most severe period of the pandemic, and remained \\nat a stable value for the rest of the time, and there was \\nalso a phenomenon of continuous ri se. \\nREFERENCES  \\n[1] Yahoo is now a part of Verizon Media. (n.d.). \\nYahoo. Retrieved August 29, 2021, from \\nhttps://finance.yahoo.com/quote/AAPL/chart? \\\\ \\n[2] Ziemba, W. T. (2020, June 21). The COVID -19 \\nCrash in the US Stock Market. Ziemba. \\nhttps://papers.ssrn.com/sol3/papers.cfm?abstract_i\\nd=3632410  \\n[3] Yan, B. (2020, March 28). Anal ysis of the Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies. Yan. \\nhttps://papers.ssrn.com/sol3/Papers.cfm?abstract_i\\nd=3563380  \\n[4] Camba, J. A. C. (2020). The Effect s of Restrictions \\nin Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance,\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 80%|████████  | 4/5 [00:46<00:13, 13.45s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'source': 'The Journal of Asian Finance, Economics and Business | Korea Science', 'link': 'https://www.koreascience.or.kr/article/JAKO202034651879125.page', 'name': 'Insights From Apple And Google Mobility Indicators'}), Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'author': 'Shivaani, M. V.', 'source': 'Journal of Emerging Technologies in Accounting', 'link': 'https://meridian.allenpress.com/jeta/article-abstract/doi/10.2308/JETA-2020-045/464597/Comparing-Apple-to-Amazon-Just-a-Matter-of-Words', 'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), Node(id='Apple (Aapl) Vs Microsoft (Msft): Which Is A Better Tech Stock To Buy Right Now?', type='Article', properties={'date': '28 Jan. 2021', 'source': 'www.nasdaq.com', 'link': 'https://www.nasdaq.com/articles/apple-aapl-vs-microsoft-msft%3A-which-is-a-better-tech-stock-to-buy-right-now-2021-01-28', 'name': 'Apple (Aapl) Vs Microsoft (Msft): Which Is A Better Tech Stock To Buy Right Now?'}), Node(id='Apple’S Market Capitalisation Has Fallen Below Trillion, And Microsoft Is The Only Remaining U.S. Company In The Trillion-Dollar Club', type='News', properties={'date': '24 Mar. 2020', 'source': 'Wall Street News', 'link': 'https://cn.wsj.com/articles', 'name': 'Apple’S Market Capitalisation Has Fallen Below Trillion, And Microsoft Is The Only Remaining U.S. Company In The Trillion-Dollar Club'}), Node(id='Advances In Economics, Business And Management Research', type='Journal', properties={'volume': '203', 'name': 'Advances In Economics, Business And Management Research'})] relationships=[] source=Document(page_content='in Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance, \\nEconomics and Business | Korea Science. Camba. \\nhttps://www.koreascience.or.kr/article/JAKO2020\\n34651879125.page  \\n[5] Shivaani, M. V. (n.d.). Comparing Apple to \\nAmazon: Just a Matter of Words in Machine \\nLearning World | Journal of Emerging \\nTechnologies in Accounting. Shivaani. Retrieved \\nAugust 29, 2021, from \\nhttps://meridian.allenpress.com/jeta/article -\\nabstract/doi/10.2 308/JETA -2020 -\\n045/464597/Comparing -Apple -to-Amazon -Just-a-\\nMatter -of-Words  \\n[6] Apple (AAPL) Vs Microsoft (MSFT): Which Is A \\nBetter Tech Stock To Buy Right Now?, 28 Jan. \\n2021, www.nasdaq.com/articles/apple -aapl-vs-\\nmicrosoft -msft%3A -which -is-a-better -tech-stock-\\nto-buy-right -now-2021 -01-28. \\n[7] Osipovich Alexander. “Apple’s market capitalisation \\nhas fallen below trillion, and Microsoft is the only \\nremaining U.S. company in the trillion -dollar \\nclub. ” Wall Street News, 24 Mar. 2020, \\ncn.wsj.com/articles /  \\nAdvances in Economics, Business and Management Research, volume 203\\n376', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 5/5 [00:58<00:00, 11.64s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes list : 30\n",
      "Distinct nodes : 26\n",
      "Relationships : 17\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from langchain.text_splitter import TokenTextSplitter\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from datetime import datetime\n",
    "\n",
    "loader = PyPDFLoader(\"../data/Apple stock during pandemic.pdf\")\n",
    "start_time = datetime.now()\n",
    "pages = loader.load_and_split()\n",
    "# Define chunking strategy\n",
    "text_splitter = TokenTextSplitter(chunk_size=2000, chunk_overlap=20)\n",
    "chunks = text_splitter.split_documents(pages)\n",
    "\n",
    "distinct_nodes = set()\n",
    "nodes = []\n",
    "relations = []\n",
    "\n",
    "for i, chunk in tqdm(enumerate(chunks), total=len(chunks)):\n",
    "    graph_document=extract_and_store_graph(chunk)\n",
    "    \n",
    "    #Get distinct nodes\n",
    "    for node in graph_document.nodes :\n",
    "        nodes.append(node.id)\n",
    "        distinct_nodes.add(node.id)\n",
    "         \n",
    "    #Get all relations   \n",
    "    for relation in graph_document.relationships :\n",
    "        relations.append(relation.type)\n",
    "\n",
    "print(\"nodes list :\", len(nodes))\n",
    "print(\"Distinct nodes :\",len(distinct_nodes))\n",
    "print(\"Relationships :\",len(relations))        "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81f63bf4",
   "metadata": {},
   "source": [
    "# With 5000 chunk size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "3f7763fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/5 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'name': 'Apple', 'location': 'Cupertino, California', 'founded': 'April 1, 1976', 'industry': 'Technology', 'revenue': 'USD $274.52 billion (2020)', 'marketcapitalization': 'USD $2.43 trillion (2021)'})] relationships=[] source=Document(page_content='The Changes of Apple’s Stock Price During the \\nPandemic  \\nWanting Sun1,* \\n1WendySun, Kinglee High School, Zheng Zhou, He Nan, China, 450000  \\n*Corresponding author. Email:  wendysun040718@163.com  \\nABSTRACT  \\nDuring the epidemic, the economies of various countries, including many large companies, were subject to very large \\nfluctuations and impacts. Therefore, this article will explore the ups and downs of Apple\\'s stock price duri ng the \\nepidemic. At different points in time and severity, Apple\\'s stock price has risen and fallen. By observing the data on \\nYahoo, we can summarize Apple\\'s stock price changes during this period. At the beginning of the epidemic, the global \\neconomy has b een damaged, so Apple is no exception. So at the beginning of the epidemic, Apple\\'s stock price fell \\nsharply. But later, because Apple had a strong overall strength and a good foundation, it only took three months to \\nsolve the impact of the epidemic. Later , when the epidemic returned to a serious situation, Apple\\'s stock price was \\nimplicated and fell slightly, but within a few weeks the stock price decline was resolved and returned to normal levels, \\nand even steadily increased. Because Apple has been consta ntly launching new products, the epidemic will not have a \\nvery large impact on Apple\\'s stock price.  \\nKeywords:  Apple, stock price, COVID -19  \\n1. INTRODUCTION  \\nAs we know, the outbreak of the epidemic in 2020 \\nhas dealt a lot of blows to many countries and \\ncompanies. Population decline, massive economic \\nlosses, and national unrest. The U.S. economic \\nrecession seems to be more serious than expected. The \\neuro zone economy has experienced the largest decline \\nin record, and the British economy  has also suffered the \\nlargest decline since World War II. As an exogenous \\nshock, the epidemic will inevitably have a direct impact \\non China\\'s transportation, tourism and other industries. \\nSimilarly, as China is the main source of power to \\npromote world gr owth, once the Chinese economy is \\naffected, the world economy will inevitably be affected. \\nThus, in such an environment where the whole world is \\naffected, to what extent have the industry giants that \\ndominate the world been hit? Let\\'s take the most \\nfamilia r Apple company as an example, and analyze \\nhow much impact this devastating epidemic has brought \\nto Apple’s stocks in several aspects . \\n \\n 2. BACKGROUND INFORM ATION OF \\nAPPLE COMPANY  \\nApple Inc. is an American multinational technology \\ncompany that specializes in consumer electronics, \\ncomputer software, and online services. In it’s \\nheadquartered in Cupertino, California. Apple went \\npublic on December 12, 1980, and set a record of \\n$623.5 billion in market value in 2012. As of June \\n2014, Apple has become the world \\'s largest company by \\nmarket capitalization for three consecutive years. On \\nSeptember 30, 2013, in the Hongmeng Group\\'s \"Best \\nGlobal Brand\" report, Apple surpassed Coca -Cola to \\nbecome the world\\'s most valuable brand. In 2014, the \\nApple brand surpassed Goog le to become the world\\'s \\nmost valuable brand. On August 19, 2020 local time, \\nApple\\'s market value exceeded US$2 trillion for the \\nfirst time. Ranked 6th on the Fortune Global 500 list in \\n2021. Apple is the world\\'s largest technology company \\nby revenue and, since January 2021, the world\\'s most \\nvaluable company. As of 2021, Apple is the world\\'s \\nfourth -largest PC vendor by unit sales, and fourth -\\nlargest smartphone manufacturer.  \\n \\nAdvances in Economics, Business and Management Research, volume 203\\nProceedings of the 2021 3rd International Conference on Economic Management and\\nCultural Industry (ICEMCI 2021)\\nCopyright © 2021 The Authors. Published by Atlantis Press International\\xa0B.V.\\nThis is an open access article distributed under the CC BY-NC 4.0 license -http://creativecommons.org/licenses/by-nc/4.0/. 373', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 0})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 20%|██        | 1/5 [00:05<00:21,  5.38s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Macroperspective', type='Perspective', properties={'description': 'From a macro perspective, the decline in population, the decrease in spending, and the increase in inventories have caused many industries to stagnate. This is bound to bring a huge blow on the global economy to a serious extent.', 'name': 'Macroperspective'}), Node(id='Globaleconomy', type='Economy', properties={'impact': \"The International Monetary Fund stated in the 'April 2020 Global Economic Survey' that due to the new crown epidemic, the global economy is expected to shrink by 3% in 2020, and the impact will be much more severe than the 2008-2009 financial crisis.\", 'name': 'Globaleconomy'}), Node(id='Epidemicimpact', type='Impact', properties={'comparisontofinancialcrisis': 'Some experts have predicted that the impact of the epidemic crisis on economic contraction will be three times that of the financial crisis.', 'name': 'Epidemicimpact'}), Node(id='Globalrecession', type='Recession', properties={'startyear': '2007', 'endyear': '2009', 'name': 'Globalrecession'}), Node(id='Apple', type='Company', properties={'componentsproductionlocation': 'China', 'name': 'Apple'}), Node(id='Applestock', type='Stock', properties={'lowestpriceduringepidemic': '56.09', 'peakprice': '134.18', 'lowestpriceafterpeak': '106.84', 'name': 'Applestock'})] relationships=[Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Globaleconomy', type='Economy', properties={'name': 'Globaleconomy'}), type='hasImpact'), Relationship(source=Node(id='Macroperspective', type='Perspective', properties={'name': 'Macroperspective'}), target=Node(id='Epidemicimpact', type='Impact', properties={'name': 'Epidemicimpact'}), type='hasImpact'), Relationship(source=Node(id='Globalrecession', type='Recession', properties={'name': 'Globalrecession'}), target=Node(id='Globaleconomy', type='Economy', properties={'name': 'Globaleconomy'}), type='hasImpact'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Applestock', type='Stock', properties={'name': 'Applestock'}), type='hasStock')] source=Document(page_content='3. MACRO PERSPECTIVE   \\nFrom a macro perspective, the decline in population, \\nthe decrease in spending, and the increase in inventories \\nhave caused many industries to stagnate. This is bound \\nto bring a huge blow on the global economy to a serious \\nextent. The International Monetary  Fund stated in the \\n\"April 2020 Global Economic Survey\" that due to the \\nnew crown epidemic, the global economy is expected to \\nshrink by 3% in 2020, and the impact will be much \\nmore severe than the 2008 -2009 financial crisis. Some \\nexperts have predicted tha t the impact of the epidemic \\ncrisis on economic contraction will be three times that \\nof the financial crisis. The last global economic \\nrecession began at the end of 2007 and did not fully \\nrecover until June 2009. Most of Apple\\'s components \\nare produced in China, so when China is affected by the \\nepidemic and the work is stopped, Apple\\'s products \\ncannot be made at the same time [3]. This will \\ninevitably have a huge impact on Apple. According to \\ninformation reported by the Wall Street Journal on \\nMarch 24, 2020 , Apple\\'s stock price closed down 2.12% \\non Monday, and its market value fell below US$1 trillion to US$981.7 billion. In this way, Apple fell out \\nof the \"trillion club\" of US stocks, of which only \\nMicrosoft was left [7].  \\n4. MICRO PERSPECTIVE  \\nIt is obvious that Apple has been affected by the \\nepidemic in a great extent, however, we still need to \\ntake a look Apple’s economic changes in a micro \\nperspective. At the beginning of the epidemic, which is \\nthe start of February, the price started to decline. On \\nFebrua ry 3, 2020, the opening price is 76.07; the \\nclosing price is 80.01. From this point, the closing price \\nstarted to diminish. On March 23, 2020, the opening \\nprice is 57.02, and the closing price is 56.09. The stock \\nprice for this day is the lowest price duri ng epidemic in \\nApple. Then, it started to increase gradually until \\nSeptember 1, this day is also a peak, the opening price \\non September 1 is 132.76 and the closing price is \\n134.18. However, after September 1, the price started to \\ndrop again. There is a ver y low price on September 18, \\n2020. The opening price is 110.40, the closing price is \\n106.84.  \\n \\nFigure 1 Apple\\'s stock price  \\n \\n \\nAdvances in Economics, Business and Management Research, volume 203\\n374', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 1})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 40%|████      | 2/5 [00:20<00:32, 10.84s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Apple', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Apple'}), Node(id='Microsoft', type='Company', properties={'founded': 'April 4, 1975', 'headquarters': 'Redmond, Washington', 'founders': 'Bill Gates, Paul Allen', 'name': 'Microsoft'})] relationships=[] source=Document(page_content=\"Figure 2.  Apple's stock price  \\nThe reasons which caused this drop might be a lot, \\nthe most common answer might be the delay of the \\nannouncement of new Apple Products. A numbers of \\npeople waiting on this day for a long time, because \\nApple supposed to announce the new products like \\niPhone  12, iPhone 12 Pro and iPhone 12 Pro Max, etc. \\nNevertheless, Apple delayed the publish of their new \\nproducts until October 14, 2020. There is a small peak \\nof rising stock price on October 12, which is two days \\nbefore the publish of the new products. The in creasing \\nof Apple stock might because people putted huge \\nexpectations on these new products, and they have been \\nwaited for a long period. This motivation lead them to \\nbuy these products right away, which caused the \\nsuddenly increasing price of Apple’ stock . On \\nNovember 2, there is a small drop on this day. The \\nopening price is 109.11, and the closing price is 108.77. \\nOn December 28, there is another increasing peak on \\nApple’s stock. The opening price is 133.99, and the \\nclosing price 136.69. This is also the  highest price of \\nApple stock in 2020. After 2020, Apple's stock price \\nwill continue to increase in 2021. This study used two \\nyears of data for comparison, which means it will only \\nuse data from February 3, 2021 and before. So at the \\nbeginning of 2021, App le’s stock price ushered in its \\nfirst peak. On January 26, 2021, the opening price is \\n143.6, and the closing price is 143.16. Later on, there is \\na small drop until February 3, 2021. The opening price \\nis 135.76, and the closing price is 133.94. Comparing \\nthe data at the same day but different year on February \\n3, we can see that the price of Apple’s stock increased \\nby 67.4% in one year.  5. COMPARISON WITH M ICROSOFT \\nCOMPANY  \\nAnother very famous company which can compete \\nwith Apple is Microsoft Company. Microsof t is an \\nAmerican multinational technology company founded \\nby Bill Gates and Paul Allen on April 4, 1975. The \\ncompany is headquartered in Redmond, Washington \\n(near Seattle), focusing on R&D, manufacturing, \\nlicensing and providing a wide range of computer \\nsoftware services. The most famous and best -selling \\nproducts are Windows operating system and Office \\nseries software. It is the world's largest computer \\nsoftware provider and the leader of PC (Personal \\nComputer) software development in the world. On June \\n23, 2021, Microsoft's market value exceeded the $2 \\ntrillion mark. This is the second US company to enter \\nafter Apple's breakthrough of $2 trillion. In 2019, the \\nmarket value of Microsoft reached US$1 trillion for the \\nfirst time, 33 years after the original Mi crosoft IPO. \\nFrom 1 trillion to 2 trillion, Microsoft only took about 2 \\nyears. Comparing Microsoft and Apple, Microsoft has \\nmore patents, company environment, R&D ratio, and \\nR&D investment than Apple. Apple's profit, profit \\nmargin, revenue, etc. are more t han that of Microsoft. \\nThis is why Apple’s market value can break 2 trillion \\nearlier than Microsoft. On the two items of profit and \\nprofit margin, Microsoft's performance is not good. \\nAfter all, it is an enterprise -level market. If the profit \\nmargin is too  high, customers are easy to lose.  \\nDuring the epidemic, Microsoft let their employees \\nto work at home, Its stock price has also changed more \\nor less with the epidemic flow. In March 6, 2020 report, \\nAdvances in Economics, Business and Management Research, volume 203\\n375\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 2})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 60%|██████    | 3/5 [00:24<00:15,  7.98s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Microsoft', type='Company', properties={'stockpriceplummeted': '14.74%', 'largestsingledaydrop': 'April 24, 2000', 'stockpricefallen': '27%', 'name': 'Microsoft'}), Node(id='Monday', type='Day', properties={'name': 'Monday'}), Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), Node(id='March 23', type='Date', properties={'name': 'March 23'}), Node(id='March 16', type='Date', properties={'name': 'March 16'}), Node(id='140.0', type='Price', properties={'name': '140.0'}), Node(id='135.42', type='Price', properties={'name': '135.42'}), Node(id='Apple', type='Company', properties={'lowestpricedate': 'March 23', 'openingprice': '140.0', 'closingprice': '135.42', 'marketvalue': 'higher than Microsoft', 'name': 'Apple'}), Node(id='August', type='Month', properties={'name': 'August'}), Node(id='November', type='Month', properties={'name': 'November'}), Node(id='Early 2021', type='Year', properties={'name': 'Early 2021'}), Node(id='67.4%', type='Percentage', properties={'name': '67.4%'})] relationships=[Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Monday', type='Day', properties={'name': 'Monday'}), type='stockPricePlummetedOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='April 24, 2000', type='Date', properties={'name': 'April 24, 2000'}), type='largestSingleDayDropSince'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='February 10, 2020', type='Date', properties={'name': 'February 10, 2020'}), type='stockDecreaseSince'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 23', type='Date', properties={'name': 'March 23'}), type='lowestPriceOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='March 16', type='Date', properties={'name': 'March 16'}), type='lowestPriceOn'), Relationship(source=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), target=Node(id='Apple', type='Company', properties={'name': 'Apple'}), type='marketValueComparison'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='August', type='Month', properties={'name': 'August'}), type='impactOfNewProducts'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='November', type='Month', properties={'name': 'November'}), type='impactOfNewProducts'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Early 2021', type='Year', properties={'name': 'Early 2021'}), type='peak'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='stockPriceComparison'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='transactionVolumeComparison'), Relationship(source=Node(id='Apple', type='Company', properties={'name': 'Apple'}), target=Node(id='Microsoft', type='Company', properties={'name': 'Microsoft'}), type='tradingVolumeComparison')] source=Document(page_content=\"Microsoft's stock price plummeted 14.74% on Monday, \\nthe la rgest single -day drop since April 24, 2000. At that \\ntime, Microsoft's stock price fell by 15.6%. In the past \\nmonth, Microsoft's stock price has fallen by 27%, and \\nthe Dow has fallen by 31% [5].  \\nIn a micro perspective, during epidemic time, \\nMicrosoft’s stoc k start decrease since February 10, \\n2020. At the time when Apple had their its lowest price \\non March 23, Microsoft also having a bad situation, but \\nthe lowest price of Microsoft price is on March 16. The \\nopening price on that day is 140.0, the closing pric e is \\n135.42. Even thought the stock price of Microsoft is \\nmuch higher than Apple, but their volume is quite \\nsimilar, even Apple’s volumes are higher than \\nMicrosoft. It is because Apple's market value is higher \\nthan Microsoft.  \\n6. OVERALL TREND  \\nFor Apple, th e epidemic only affected it at the \\nbeginning, but it took only four months for Apple to \\nreturn to its previous normal stock price. It can be seen \\nthat the true hidden strength behind Apple can enable \\nApple. Recovered in such a short time. The overall \\nsitua tion of Apple's stock price continued to rise. It only \\nfell sharply between February and June, when the \\nepidemic first began, but it quickly returned to its \\noriginal state. During the period from August to \\nNovember, the impact of Apple's new products rose \\nfirst and then fell back to normal levels. There was also \\na peak in early 2021, and then it returned to normal \\nlevels. The overall level of Apple's stock increased by \\n67.4% over the same period.  \\nFor Microsoft, his situation is actually similar to that \\nof the same type of Apple. At the beginning of the \\nepidemic, there was a huge decline from February to \\nMarch, but it was basically fully restored to the \\nprevious level before June. Like Apple, it took just four \\nmonths to solve the severe damage caused by the \\nepidemic, which shows that Microsoft's strength cannot \\nbe underestimated. Microsoft's overall trend continues \\nto rise. However, unlike Apple, the highest value of \\nApple's stock is in December, which is the end of 2020, \\nbut the highest value of Microsoft's s tock is in \\nSeptember. After September, the stock declined \\nslightly, but it only fell to a normal level, and then \\nslowly climbed up.  \\n7. CONCLUSION  \\nComparing Apple's stock price and Microsoft's \\nstock price, we can find that Microsoft's stock price is \\nmuch h igher than Apple's, but when we compare their \\nnumber of transactions, we find that Apple's number of \\ntransactions is many times greater than that of \\nMicrosoft. This has also led to the fact that the total \\ntrading volume of Apple stock and Microsoft stock i s similar, and sometimes Apple is even higher than \\nMicrosoft.  \\nTo conclude, the pandemic did not bring an \\nirreparable blow to Apple. Instead, it only took it four \\nmonths to restore its stock to its original value, or even \\nrise. This is enough to show that Apple's foundation is \\nstable and there are excellent strategies to enable them \\nto recover their losses in time when they faced strong \\nimpacts. In general, Apple's stock only declined during \\nthe most severe period of the pandemic, and remained \\nat a stable value for the rest of the time, and there was \\nalso a phenomenon of continuous ri se. \\nREFERENCES  \\n[1] Yahoo is now a part of Verizon Media. (n.d.). \\nYahoo. Retrieved August 29, 2021, from \\nhttps://finance.yahoo.com/quote/AAPL/chart? \\\\ \\n[2] Ziemba, W. T. (2020, June 21). The COVID -19 \\nCrash in the US Stock Market. Ziemba. \\nhttps://papers.ssrn.com/sol3/papers.cfm?abstract_i\\nd=3632410  \\n[3] Yan, B. (2020, March 28). Anal ysis of the Effect of \\nCOVID -19 on the Stock Market and Investing \\nStrategies. Yan. \\nhttps://papers.ssrn.com/sol3/Papers.cfm?abstract_i\\nd=3563380  \\n[4] Camba, J. A. C. (2020). The Effect s of Restrictions \\nin Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance,\", metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 80%|████████  | 4/5 [00:44<00:12, 12.67s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes=[Node(id='Economic Activity On The Spread Of Covid-19 In The Philippines', type='Topic', properties={'name': 'Economic Activity On The Spread Of Covid-19 In The Philippines'}), Node(id='Insights From Apple And Google Mobility Indicators', type='Article', properties={'source': 'The Journal of Asian Finance, Economics and Business | Korea Science', 'link': 'https://www.koreascience.or.kr/article/JAKO202034651879125.page', 'name': 'Insights From Apple And Google Mobility Indicators'}), Node(id='Comparing Apple To Amazon: Just A Matter Of Words', type='Article', properties={'author': 'Shivaani, M. V.', 'source': 'Journal of Emerging Technologies in Accounting', 'link': 'https://meridian.allenpress.com/jeta/article-abstract/doi/10.2308/JETA-2020-045/464597/Comparing-Apple-to-Amazon-Just-a-Matter-of-Words', 'name': 'Comparing Apple To Amazon: Just A Matter Of Words'}), Node(id='Apple (Aapl) Vs Microsoft (Msft): Which Is A Better Tech Stock To Buy Right Now?', type='Article', properties={'date': '28 Jan. 2021', 'source': 'www.nasdaq.com', 'link': 'https://www.nasdaq.com/articles/apple-aapl-vs-microsoft-msft%3A-which-is-a-better-tech-stock-to-buy-right-now-2021-01-28', 'name': 'Apple (Aapl) Vs Microsoft (Msft): Which Is A Better Tech Stock To Buy Right Now?'}), Node(id='Apple’S Market Capitalisation Has Fallen Below Trillion, And Microsoft Is The Only Remaining U.S. Company In The Trillion-Dollar Club', type='News', properties={'date': '24 Mar. 2020', 'source': 'Wall Street News', 'link': 'https://cn.wsj.com/articles', 'name': 'Apple’S Market Capitalisation Has Fallen Below Trillion, And Microsoft Is The Only Remaining U.S. Company In The Trillion-Dollar Club'}), Node(id='Advances In Economics, Business And Management Research', type='Journal', properties={'volume': '203', 'name': 'Advances In Economics, Business And Management Research'})] relationships=[] source=Document(page_content='in Economic Activity on the Spread of COVID -19 \\nin the Philippines: Insights from Apple and Google \\nMobility Indicators -The Journal of Asian Finance, \\nEconomics and Business | Korea Science. Camba. \\nhttps://www.koreascience.or.kr/article/JAKO2020\\n34651879125.page  \\n[5] Shivaani, M. V. (n.d.). Comparing Apple to \\nAmazon: Just a Matter of Words in Machine \\nLearning World | Journal of Emerging \\nTechnologies in Accounting. Shivaani. Retrieved \\nAugust 29, 2021, from \\nhttps://meridian.allenpress.com/jeta/article -\\nabstract/doi/10.2 308/JETA -2020 -\\n045/464597/Comparing -Apple -to-Amazon -Just-a-\\nMatter -of-Words  \\n[6] Apple (AAPL) Vs Microsoft (MSFT): Which Is A \\nBetter Tech Stock To Buy Right Now?, 28 Jan. \\n2021, www.nasdaq.com/articles/apple -aapl-vs-\\nmicrosoft -msft%3A -which -is-a-better -tech-stock-\\nto-buy-right -now-2021 -01-28. \\n[7] Osipovich Alexander. “Apple’s market capitalisation \\nhas fallen below trillion, and Microsoft is the only \\nremaining U.S. company in the trillion -dollar \\nclub. ” Wall Street News, 24 Mar. 2020, \\ncn.wsj.com/articles /  \\nAdvances in Economics, Business and Management Research, volume 203\\n376', metadata={'source': '../data/Apple stock during pandemic.pdf', 'page': 3})\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 5/5 [00:53<00:00, 10.74s/it]\n"
     ]
    }
   ],
   "source": [
    "from langchain.text_splitter import TokenTextSplitter\n",
    "from langchain_community.document_loaders import PyPDFLoader\n",
    "from datetime import datetime\n",
    "\n",
    "loader = PyPDFLoader(\"../data/Apple stock during pandemic.pdf\")\n",
    "start_time = datetime.now()\n",
    "pages = loader.load_and_split()\n",
    "# Define chunking strategy\n",
    "text_splitter = TokenTextSplitter(chunk_size=5000, chunk_overlap=20)\n",
    "chunks = text_splitter.split_documents(pages)\n",
    "\n",
    "distinct_nodes = set()\n",
    "nodes = []\n",
    "relations = []\n",
    "\n",
    "for i, chunk in tqdm(enumerate(chunks), total=len(chunks)):\n",
    "    graph_document=extract_and_store_graph(chunk)\n",
    "    \n",
    "    #Get distinct nodes\n",
    "    for node in graph_document.nodes :\n",
    "        nodes.append(node.id)\n",
    "        distinct_nodes.add(node.id)\n",
    "         \n",
    "    #Get all relations   \n",
    "    for relation in graph_document.relationships :\n",
    "        relations.append(relation.type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a075cfa5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nodes list : 28\n",
      "Distinct nodes : 24\n",
      "Relationships : 16\n"
     ]
    }
   ],
   "source": [
    "print(\"nodes list :\", len(nodes))\n",
    "print(\"Distinct nodes :\",len(distinct_nodes))\n",
    "print(\"Relationships :\",len(relations))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
